akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
#define N 100004
long long t[N], DP[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long n, cost = 0, pos = 1;
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> t[i];
    DP[2] = abs(t[2] - t[1]);
    for (long long i = 3; i <= n; i++) DP[i] = min(abs(t[i] - t[i - 2]) + DP[i - 2], abs(t[i] - t[i - 1]) + DP[i - 1]);
    cout << DP[n];
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int l, a[6];
	for(int i=0; i<6; i++) {
		cin >> l;
		a[i] = l;
		//cout << l;
	}
	if ((a[4] - a[0]) > a[5]) {
		cout << ":(" << endl;
		return 0;
	}
	cout << "Yay!" << endl;
}



Measured memory_bytes: 256
f a b
    | a < b = (show a ++ " " ++ show b):f (a + 1) (b - 1)
    | otherwise = []

main = do
    [n, m] <- map read . words <$> getLine :: IO [Int]
    let n' = div n 2
    let ab = if mod n 2 == 1
        then f 1 n
        else f 1 (n' - 1) ++ f (n' + 1) n
    mapM_ putStrLn $ take m ab


Measured memory_bytes: 4988
#include <iostream>
#include <iomanip>
 int main() {
  int a, b;
  std::cin >> a >> b; 
  std::cout << a/b <<std::endl;
  std::cout << a%b <<std::endl;
  double f;
  f = 1.0 * a/b;
  std::cout << std::fixed << std::setprecision(5) << f <<std::endl;




 return 0;


}


Measured memory_bytes: 3220
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int main() {
	string s;
	int n;
	while (cin >> n && n) {
		map<string, int> data;
		vector<pair<int, string> > v;
		char c;
		getchar();
		while (n--) {
			getline(cin, s);
			stringstream ss(s);
			while (ss >> s)data[s]++;
		}
		cin >> c;
		for (auto i = data.begin(); i != data.end(); i++) {
			if (c == i->first[0]) {
				v.emplace_back(make_pair(-i->second, i->first));
			}
		}
		sort(ALL(v));

		if (v.empty()) cout << "NA" << endl;
		else {
			REP(i, min((int)v.size(), 5)) {
				if (i)cout << " ";
				cout << v[i].second;
			}
			cout << endl;
		}
	}
}



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

using namespace std;

struct LCA {
    vector<vector<long>> park;
    vector<long> h;
    long n, d;

    LCA(vector<long> &par) {
        // par[root] == -1
        n = par.size();
        h.assign(n, -1);
        {
            auto dfs = [&](auto dfs, long cur) -> long {
                if(par[cur] == -1) return h[cur] = 0;
                if(h[cur] != -1) return h[cur];
                return h[cur] = 1 + dfs(dfs, par[cur]);
            };
            for(long i=0; i<n; i++)
                dfs(dfs, i);
        }

        d=1;
        while(1L<<d < n) d++;

        park.assign(d, vector<long>(n));
        copy(par.begin(), par.end(), park[0].begin());

        for(long k=1; k<d; k++)
            for(long i=0; i<n; i++) {
                if(park[k-1][i] == -1) continue;
                park[k][i] = park[k-1][park[k-1][i]];
            }
    }

    long query(long u, long v) const {
        if(h[u] > h[v])
            swap(u, v);
        for(long i=d-1; i>=0; i--)
            if(h[v]-h[u] >= 1L<<i)
                v = park[i][v];

        if(v == u) return v;

        for(long i=d-1; i>=0; i--)
            if(park[i][v] != park[i][u])
                v = park[i][v], u = park[i][u];
        return park[0][v];
    }
};

int main(void) {
    /* long n, q; */
    /* cin >> n >> q; */
    long n;
    cin >> n;
    vector<long> par(n, -1);
    /* for(int i=1; i<n; i++) */
    /*     cin >> par[i]; */

    for(int i=0; i<n; i++) {
        long k;
        cin >> k;
        for(int j=0; j<k; j++) {
            long c;
            cin >> c;
            par[c] = i;
        }

    }

    LCA lca(par);

    long q;
    cin >> q;

    for(long i=0; i<q; i++) {
        long u, v;
        cin >> u >> v;
        cout << lca.query(u, v) << endl;
    }
}



Measured memory_bytes: 18468
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

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); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,p,ans = 1;
	cin >> n >> p;
	int q = p;
	for(int i = 2;i * i <= p;i++){
		int cnt = 0;
		while(q % i == 0){
			q /= i;
			cnt++;
			if(cnt % n == 0) ans *= i;
		}
	}
	if(n == 1) ans *= q;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>	
#define int long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second 
#define mod 1000000007     
using namespace std;

main()
{	
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int p = 1;
	int a, b;
	cin >> a  >> b;
	for(int i = 1; i < 100001; i++){
		int a1 = 8 * i;
		int a2 = 10 * i;
		a1 /= 100;
		a2 /= 100;
		if(a1 == a and a2 == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  res = n / 2;
  if(n % 2 != 0)res++;
  cout << res << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
set<string> T;
string S;

void dfs(int cur) {
	if(S.size()==N) {
		cout<<S<<endl;
		return;
	}
	
	for(int i=0;i<=cur;i++) {
		S+='a'+i;
		dfs((i==cur)?(cur+1):cur);
		S.pop_back();
	}
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	dfs(0);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1536
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vvint dp1;
vvint dp2;
// vector<vvint> vv;
int n;
vint v;
// int foo(int x,int y,int z){
	// if(y<0) return INF;
	// if(2*y>n) return INF;
	// if(dp[x][y][z]!=INF) return dp[x][y][z];
	// int ret=INF;
	// if(z==0){
		// reep(i,1,x){
			// ret=min(ret,foo(i,y-x+i,1)+v[x]);
		// }
		// reep(i,1,x){
			// ret=min(ret,foo(i,y-x+i,0)+v[x]-v[i]);
		// }
	// }
	// else{
		// reep(i,1,x){
			// ret=min(ret,foo(i,y,1)+v[x]-v[i]);
		// }
		// reep(i,1,x){
			// ret=min(ret,foo(i,y,0)+v[x]);
		// }
	// }
	// return dp[x][y][z]=ret;
// }

void mainmain(){
	// rep(i,10002) rep(j,5002) rep(k,2) dp[i][j][k]=INF;
	// dp[0][0][0]=0;
	// int n;
	cin>>n;
	initvv(dp1,n+2,2,INF);
	initvv(dp2,n+2,2,INF);
	v=vint(n+1,0);
	rep(i,n-1){
		cin>>v[i+1];
	}
	// cout<<0<<endl;
	// return;
	dp1[1][0]=dp1[0][1]=v[1];
	reep(i,2,n+1){
		rep(j,i+1){
			int ret=INF;
			if(j) ret=min(ret,dp1[j-1][1]+v[i]);
			if(j) ret=min(ret,dp1[j-1][0]+v[i]-v[i-1]);
			dp2[j][0]=ret;
			// cout<<i<<" "<<j<<" "<<0<<" "<<dp2[j][0]<<endl;
			ret=INF;
			ret=min(ret,dp1[j][1]+v[i]-v[i-1]);
			ret=min(ret,dp1[j][0]+v[i]);
			dp2[j][1]=ret;
			// cout<<i<<" "<<j<<" "<<1<<" "<<dp2[j][1]<<endl;
		}
		dp1=dp2;
		// break;
	}
	int ans=min(dp1[n/2][0],dp1[n/2][1]);
	// rep(i,n+1){
		// rep(j,n+1){
			// rep(k,2){
				// cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
			// }
		// }
	// }
	cout<<ans<<endl;
	// reep(i,1,n){
		// reep(j,)
	// }
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 2344
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, m, sum;
map<int, int>mp;
signed main() {
	cin >> n >> m;
	mp[0] = 1;
	int ans = 0;
	rep(i, n) {
		int a; cin >> a;
		sum += a;
		ans += mp[sum % m];
		mp[sum % m]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4224
import bisect
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
ls = sorted(l,key=lambda x:x[1])
dict = {}
for i in ls:
    p,y = i
    if not p in dict.keys():
        dict[p] = []
        dict[p].append(y)
    else:
        dict[p].append(y)
for j in l:
    p,y = j
    print('{:0=6}'.format(p)+'{:0=6}'.format(bisect.bisect_left(dict[p],y) + 1))
    



Measured memory_bytes: 43008
list = list(map(int, input().split())) 
hajime=list[0]
kaisuu=list[1]
hohaba=list[2]
if hajime>=0:
  ayumi=hajime//hohaba
  nokori=kaisuu-ayumi
  kouho_1=hajime-hohaba*kaisuu
  kouho_2=hajime-hohaba*ayumi
  kouho_3=hajime-hohaba*(ayumi+1)
 
  
  
  if kaisuu <= ayumi:
    print(kouho_1)
  else:
    if nokori%2==0:
      print(kouho_2)
    else:
      print(-kouho_3)
      
if hajime<0:  
  ayumi=-hajime//hohaba
  nokori=kaisuu-ayumi
  kouho_1=hajime+hohaba*kaisuu
  kouho_2=hajime+hohaba*ayumi
  kouho_3=hajime+hohaba*(ayumi+1)
  if kaisuu<=ayumi:
    
    print(-kouho_1)  
  else:
    if nokori%2==0:
      print(-kouho_2)
    else:
      print(kouho_3)

Measured memory_bytes: 61916
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define vi vector <int>
#define endl "\n"
#define f(n) for(int i=0;i<n;i++)
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd __gcd
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define setBits(x) __builtin_popcountll(x)
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define N 100005
#define mod 1000000007
double dp[3001][3001];
vector<double> v(1000000);
double fun(int i,int x)
{
	if(x==0)
	{
		return 1;
	}
	if(i==0)
	{
		return 0;
	}
	if(dp[i][x]>-0.9)
	{
		return dp[i][x];
	}
	//cout<<v[i]<<endl;
	dp[i][x]=((v[i]*fun(i-1,x-1)*1.0)+((1.0-v[i])*fun(i-1,x)*1.0)*1.0);
	return dp[i][x];
}
void solve()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>v[i];
	double x=fun(n,(n/2)+1);
	cout<<fixed<<setprecision(10)<<x<<endl;
	return ;	
}
signed main()
{
	for(int i=0;i<3001;i++)
	{
		for(int j=0;j<3001;j++)
		{
			dp[i][j]=-1.0;
		}
	}
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    	//cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 81692
while True:
    a, op, b = input().split()
    a, b = [int(x) for x in [a, b]]
    
    if op == "+":
        print(f"{a+b}")

    elif op == "-":
        print(f"{a-b}")

    elif op == "*":
        print(f"{a*b}")

    elif op == "/":
        print(f"{a//b}")

    else:
        break



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

int main(){

  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin>>k;
  
  cout<<a[k-1]<<endl;

}

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

long long gcd(long long a, long long b){
  long long r = a%b;
  if(r!=0) return gcd(b,r);
  else if(r==0) return b;
}

long long lcm(long long a,long long b,long long g){
  return a * b / g;
}

int main(){
  long long a,b;

  if(a<b) swap(a,b); 
  
  while(cin>>a>>b){
    long long g = gcd(a,b);
    cout<<g<<" "<<lcm(a,b,g)<<endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 10000000;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;
int main() {
  int n;
  cin>>n;
  vecch s;
  if(n==0){
    cout<<0<<endl;
    exit(0);
  }
  bool che=true;
  while(che){
    int k=n%(-2);
    if(k==0){
      s.push_back('0');
    }
    else{
      s.push_back('1');
      n--;
    }
    n/=-2;
    if(n==0) che=false;
  }
  reverse(all(s));
  for(int i=0;i<s.size();i++) cout<<s[i];
}


Measured memory_bytes: 256
N=int(input())
S=input()

# 各文字がどこまでにいくつ含まれるかを累積和で管理
R=[0]*N
G=[0]*N
B=[0]*N

dic={}
for c in ("R","G","B"):
  dic[c] = [0] * N

rp=0
gp=0
bp=0
for i in range(len(S)):
  if S[i]=="R":
    rp+=1
    dic["R"][i]=rp
  elif S[i]=="G":
    gp+=1
    dic["G"][i]=gp
  elif S[i]=="B":
    bp+=1
    dic["B"][i]=bp

def getRest(s1,s2):
  for c in ["R","G","B"]:
    if c not in (s1,s2):
      return c

ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    # 最初の2つの文字を固定する
    if S[i] == S[j]:
      continue
    # 探すべき文字を特定
    rest = getRest(S[i],S[j])
    ans += dic[rest][-1] - dic[rest][j]
    
    if j + (j-i) < N and S[j + (j-i)] == rest:
      ans -= 1
    
print(ans)    

Measured memory_bytes: 69176
n, k = map(int, input().split())

ans = 0
for i in range(1, n + 1):
    cnt = 0
    if i >= k:
        ans += 1 / n
    else:
        j = i
        while j < k:
            j *= 2
            cnt += 1
        
        ans += 1 / n * 0.5 ** cnt
    

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size();
}

Measured memory_bytes: 19064
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[,\\s+]");

	public static void main(String[] args){
		int r = 0;
		int d = 0;
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if((double) c == Math.hypot((double) a, (double) b)){
				r++;
			} else if(a == b){
				d++;
			}
		}
		System.out.printf("%d\n", r);
		System.out.printf("%d\n", d);
	}
}

Measured memory_bytes: 26184
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){

  int d, e;

  while(cin>>d>>e, d){
    double ans=10000;

    for(int x=0;x<=100;x++){
      for(int y=0;y<=100;y++){
	if(x+y==d) ans=min(ans, fabs(sqrt(x*x+y*y)-e));
      }
    }

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

Measured memory_bytes: 3216
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	string S, T;
	cin >> S >> T;
	
	// 解法
	
	bool ans = false;
	for (int i = 0; i < S.size(); ++i) {
		string tmp;
		tmp = S.substr(i, S.size()-i) + S.substr(0, i);
		// cout << tmp << endl;
		if (tmp==T){
			ans = true; 
			break;
		} 
	}
	
	//出力
	if (ans) printf("Yes\n");
	else  printf("No\n");
}
 


Measured memory_bytes: 256
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;


int main() {
	int N; cin >> N;
	auto sum = 0.0; 
	auto as = vector<int>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> as[i];
		sum += as[i];
	}
	int average = round(sum / N);
	int answer = 0;
	for (size_t i = 0; i < N; i++) {
		answer += (as[i] - average)*(as[i] - average);
	}
	cout << answer << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int K, S, count = 0;
    scanf("%d %d", &K, &S);

    for(int x = 0; x <= K; x++){
        for(int y = 0; y <= K; y++){
            if(0 <= S - x - y && S - x - y <= K){
                count++;
            }
        }
    }

    printf("%d\n", count);
    return 0;
}

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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  int d;
  int A;
  int B;
  for (int i=0; i<N; i++){
    int x;
    cin >> x;
    A = x*2;
    B = (K-x)*2;
    if (A<=B) {
      d += A;
    }
    else {
      d += B;
    }
  }
  
  cout << d << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())

MAX_V = N * (10 ** 3)
w, v = [], []
for _ in range(N):
    a, b = map(int, input().split())
    w.append(a)
    v.append(b)

dp = [[10**9+7 for _ in range(MAX_V + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(MAX_V + 1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j],dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]

mv = 0
for i in range(MAX_V + 1):
    if dp[N][i] <= W:
        mv = i
print(mv)


Measured memory_bytes: 171780
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/11/20 07:34:59
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  vector<string> grid(h);
  for (auto& l:grid) cin>>l;
  auto solve = [&]() {
    constexpr int dir[4][2] {
        {1,0},{0,1},
        {-1,0},{0,-1},
    };
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (grid[i][j] == '.') continue;
        bool ok = false;
        for (auto [dx, dy] : dir) {
          int x = i + dx, y = j + dy;
          if (x < 0 or x >= h or y < 0 or y >= w) continue;
          ok |= grid[x][y] == '#';
        }
        if (!ok) {
          return false;
        }
      }
    }
    return true;
  };
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


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


int main(int argc, char *args[]) {
	int N;
	int A;
	cin >> N;
	cin >> A;
	if (N % 500 > A) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	string s, t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();

	int dp[n+1][m+1];
	pii p[n+1][m+1];
	memset(dp, 0, sizeof dp);
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			if (s[i] == t[j]) {
				dp[i+1][j+1] = dp[i][j] + 1;
				p[i+1][j+1] = pii(i,j);
			} else {
				dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
				if (dp[i+1][j+1] == dp[i][j+1]) {
					p[i+1][j+1] = pii(i,j+1);
				} else {
					p[i+1][j+1] = pii(i+1,j);
				}
			}
		}
	}

	string ans;
	for (int i=n,j=m; i>0 && j>0; tie(i,j)=p[i][j]) {
		if (p[i][j].first != i && p[i][j].second != j) {
			ans.push_back(s[i-1]);
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << nl;

	return 0;
}


Measured memory_bytes: 105856
import java.util.Scanner;

public class Main {

	/**標準偏差を求める
	 *
	 * @param args 0:入力するデータの数 1~k:データの要素
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		for(;scan.hasNext();){		//苦肉の策
			int num = scan.nextInt();
			if(num == 0){			//入力データ数が0で終了
				break;
			}
//			int num = Integer.parseInt(args[k]);

			int sum = 0;
			//データ要素を配列に格納
			int[] input_set = new int[num]; 
			for(int i = 0; i < num; i++){
				input_set[i] = scan.nextInt();
			}	

			//合計値の計算
			for(int i = 0; i < num; i++){
				sum = sum + input_set[i];
			}
			double ave = (double)sum /(double)num;
			
			//標準偏差の計算
			double pow = 0;
			for(int i = 0; i < num ; i++){
				pow = pow + Math.pow(input_set[i] - ave, 2) ;
			}
			double bunsan = pow / (double)num;
			double hensa = Math.sqrt(bunsan);



			System.out.println(hensa);

		}
	}
}



Measured memory_bytes: 30976
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    A = kwargs["A"]
    B = [0 for i in range(n)]

    for i in range(n - 1):
        B[A[i] - 1] += 1

    res = "\n".join([str(i) for i in B])
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    kwargs["n"] = [int(i) for i in cin][0]
    #kwargs["n"], kwargs["k"] = [int(i) for i in cin]
    cin = input().split()
    kwargs["A"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

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

string toUpper(string x){
    string y = x;
    for(int i=0;i<x.size();i++){
        y[i] = toupper(x[i]);
    }
    return y;
}

int main(){
    int cnt=0;
    string word,word2;
    cin >> word;
    word = toUpper(word);
    cin >> word2;
    while(1){
        if(word2=="END_OF_TEXT") break;
        word2 = toUpper(word2);
        if(word==word2) cnt++;
        cin >> word2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 20:50:25 2019

@author: Yamazaki Kenichi
"""

N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]

ans = 0
for i in range(N):
    res = 0
    for j in range(M):
        res += A[i][j]*B[j]
    res += C
    if res > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N = I()
print(lcm(*IR(N)))

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ll long long
#define ld long double
#define l_b lower_bound
#define u_b upper_bound
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define heap priority_queue
#define umap unordered_map
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define test() ll t;cin>>t;while(t--)
#define mset(a,x) memset(a,x,sizeof(a))
#define rep(i,a,n) for(ll i = a; i < n; ++i) 
#define fastIO ios_base::sync_with_stdio(0);

const int inf = 1e9;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

ll dp[105][maxn];

int main() {
    // fastIO;
    ll n, s;
    cin >> n >> s;
    ll w[n+1], v[n+1];
    rep(i, 1, n+1)
        cin >> w[i] >> v[i];
    dp[0][0] = 0;
    dp[0][1] = 0;
    rep(i, 1, n+1){
        rep(j, 1, s+1){
            if(j >= w[i])
                dp[i][j] = max(dp[i-1][j-w[i]] + v[i], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    cout << dp[n][s] << endl;

    return 0;
}

Measured memory_bytes: 79360
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5;
int n, a[N];
int64 ans;
int main()
{
    n = read(); for(int i = 3*n; i; --i) a[i] = -read();
    sort(a+1, a+1+3*n);
    for(int i = 1; i <= n; ++i) ans -= a[i<<1];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX_VAL 210000

long long fac[MAX_VAL], mmi[MAX_VAL];

void factorial_mod(){
	 fac[0]=fac[1]=1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

void exgcd(int a, int b, int &x, int &y){
	if(b == 0){
		x = 1;
		y = 0;
		return ;
	}
	exgcd(b,a%b,y,x);
	y -= a/b * x;
}

void modular_multiplicatibe_inverse(){
	int x, y;  
	exgcd(fac[MAX_VAL-1],MOD,x,y);
	mmi[MAX_VAL-1] = x;
	
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

long long combination(long long n, long long r){
	return n < r ? 0 :fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, k;
	int ans = 0;
	
	cin>>n>>k;
	
	factorial_mod();
	modular_multiplicatibe_inverse();
	
	for(int i = 0; i < n && i <= k; i++){
		ans += combination(n, i) * combination(n-1, i);
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

const int MAX = 1001001;
int main()
{
	int n, m, arr[MAX];
	cin >> n >> m;
	int ans = n;
	for (int i=0; i<m; ++i) {
		cin >> arr[i];
		ans -= arr[i];
	}
	
	if (ans < 0) {
		cout << -1;
	}
	else {
		cout << ans;
	}
	
	return 0;
}


Measured memory_bytes: 3656
def main():
    s = input()
    l = 0
    r = len(s)-1
    ans = 0
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == "x":
            l += 1
            ans += 1
        elif s[r] == "x":
            r -= 1
            ans += 1
        else:
            print(-1)
            exit()
    print(ans)
    return

if __name__ == '__main__':
    main()


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

int main()
{
	int x;
	cin>>x;
	if((x>=400)&&(x<=599))
	{
		cout<<"8"<<endl;
	}
	else if((x>=600)&&(x<=799))
	{
		cout<<"7"<<endl;
	}
	else if((x>=800)&&(x<=999))
	{
		cout<<"6"<<endl;
	}
	else if((x>=1000)&&(x<=1199))
	{
		cout<<"5"<<endl;
	}
	else if((x>=1200)&&(x<=1399))
	{
		cout<<"4"<<endl;
	}
	else if((x>=1400)&&(x<=1599))
	{
		cout<<"3"<<endl;
	}
	else if((x>=1600)&&(x<=1799))
	{
		cout<<"2"<<endl;
	}
	else if((x>=1800)&&(x<=1999))
	{
		cout<<"1"<<endl;
	}
	return 0;
}

/*
From 400 through 599: 8-kyu

From 600 through 799: 7-kyu

From 800 through 999: 6-kyu

From 1000 through 1199: 5-kyu

From 1200 through 1399: 4-kyu

From 1400 through 1599: 3-kyu

From 1600 through 1799: 2-kyu

From 1800 through 1999: 1-kyu

*/

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int A[N], B[N];
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];
	priority_queue<int> que;
	int sum = 0, ans = 0;
	rep(i,N){
		if(A[i] >= B[i]){
			que.push(A[i]-B[i]);
		}
		else{
			sum += B[i]-A[i];
			++ans;
		}
	}
	if(sum == 0){
		cout << 0 << endl;
		return 0;
	}
	while(!que.empty()){
		int x = que.top();
		que.pop();
		++ans;
		sum -= x;
		if(sum <= 0) break;
	}
	if(sum <= 0) cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 2936
N, M = [int(n) for n in input().split()]
A = []
for i in range(N):
    a, b = [int(n) for n in input().split()]
    A.append((a,b))
SA = sorted(A)
ans = 0
while True:
    sa = SA.pop(0)
    if sa[1] < M:
        ans += sa[0]*sa[1]
        M -= sa[1]
    else:
        ans += sa[0] * M
        break
print(ans)


Measured memory_bytes: 23376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N,M,X;
    string S;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N,vector<ll>(M));
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }
    ll ans = 1e18;
    for(ll i=0;i<(ll(1) << N);i++){
        ll cost = 0;
        bool flag = true;
        vector<ll> B(M,0);
        rep(j,N){
            if( (i >> ll(j)) & ll(1)){
                cost += C[j];
                rep(k,M){
                    B[k] += A[j][k];
                }
            }
        }
        rep(k,M){
            if(B[k] < X){
                flag = false;
            }
        }
        if(flag){
            cmin(ans, cost);
        }
    }
    if(ans == 1e18){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

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

    int N;
    cin >> N;

    for(int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(a[j][k] == b) a[j][k] = 0;
            }
        }
    }

    for(int i = 0; i < 3; ++i) {
        int s = 0;
        for(int j = 0; j < 3; ++j) {
            s += a[i][j];
        }
        if(s == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for(int i = 0; i < 3; ++i) {
        int s = 0;
        for(int j = 0; j < 3; ++j) {
            s += a[j][i];
        }
        if(s == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(a[0][0] + a[1][1] + a[2][2] == 0 || a[2][0] + a[1][1] + a[2][0] == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


n, s = map(int, readline().split())
x = [v-s for v in list(map(int, readline().split()))]

print(abs(gcd(*x)))

Measured memory_bytes: 19156
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
#define nl "\n"
#define X first
#define Y second

#define MAX INT_MAX
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define check() {printf("OK\n");}
#define srt(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i,a,b) for(int i =(a); i <=(b); ++i)
#define maxv(v) *max_element(v.begin(),v.end())
#define minv(v) *min_element(v.begin(),v.end())

#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define f() {ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);}
#define unq(v) srt(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define MOD 1000000007   // (int)1e9+7


int main(){f();

		int n,m;
		char c;
		cin>>n>>c>>m;;
		if(c=='-'){
            cout<<n-m<<nl;
		}
		else{
            cout<<n+m<<nl;
		}







return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B,Q;
    cin >> A >> B >> Q;
    vector<ll> s(A),t(B),x(Q);
    rep(i,A){
        cin >> s[i];
    }
    rep(i,B){
        cin >> t[i];
    }
    rep(i,Q){
        cin >> x[i];
    }
    /*vector<Pll> P(A+B);
    rep(i,A){
        P[i] = Pll(s[i],0);
    }
    rep(i,B){
        P[A+i] = Pll(t[i],1);
    }
    sort(P.begin(), P.end());
    */
    rep(i,Q){
        ll ans = 1e18;
        ll si = lower_bound(s.begin(),s.end(),x[i]) - s.begin();
        ll ti = lower_bound(t.begin(),t.end(),x[i]) - t.begin();
        if(si > 0 && ti > 0){
            cmin(ans, abs(x[i] - min(s[si-1], t[ti-1])));
        }
        if(si > 0 && ti < B){
            cmin(ans, min(abs(x[i] - s[si-1]), abs(x[i] - t[ti]))*2 + max(abs(x[i] - s[si-1]), abs(x[i] - t[ti])));
        }
        if(ti > 0 && si < A){
            cmin(ans, min(abs(x[i] - s[si]), abs(x[i] - t[ti-1]))*2 + max(abs(x[i] - s[si]), abs(x[i] - t[ti-1])));
        }
        if(si < A && ti < B){
            cmin(ans, abs(x[i] - max(s[si], t[ti])));
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

int main()
{
    int y,m,n;
    cin>>n;
    y = n/100;
    m = n - y*100;
//    cout << y <<"年"<<m<<"月"<<endl;
//    cout << m <<"年"<<y<<"月"<<endl;
    if(1<=y&&y<=12&&1<=m&&m<=12){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(1<=y&&y<=12){
        cout<<"MMYY"<<endl;
    }
    else if(1<=m&&m<=12){
        cout<<"YYMM"<<endl;
    }
    else {
        cout<<"NA"<<endl;
    }
    return 0;
}


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

namespace coder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(s=>Convert.ToInt64(s)).ToArray();
            long ans = 0;
            long temp = 0;
            
            long ini = nk[0];
            long judge = nk[0] - nk[1];
            nk[0] = nk[0] % nk[1];

            if(nk[0] == 0) 
            {
                ans = 0;
           
            }
            else
            {
                ans = nk[0] > Math.Abs(nk[0] - nk[1]) ? Math.Abs(nk[0] - nk[1]) : nk[0];
            }

            
            Console.WriteLine(ans);

           
        }
    }
}


Measured memory_bytes: 13268
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[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)*}
    };

    ($next:expr, mut $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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: usize,
        b: usize,
    );

    let mut ans = a + b;
    ans = max(ans, a + a-1);
    ans = max(ans, b + b-1);
    println!("{}", ans);

}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572