akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  REP(i, A) {
    if (!('0' <= S.at(i) && S.at(i) <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (S.at(A) != '-') {
    cout << "No" << endl;
    return 0;
  }

  REP(i, B) {
    if (!('0' <= S.at(A + 1 + i) && S.at(A + 1 + i) <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

using namespace std;

int main(){
    int s;
    cin>>s;
    int n=0,m=s;
    while (m>=15) {
        m=m-15;
        n++;
    }
    cout<<800*s-200*n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,dp[200005],s[200005],b[200005],z[200005],ans;
struct T{
	ll x,y,z,i;
	void plus(T &q){
		z=(z*(q.x+q.y+q.z)%M+y*(q.y+q.z)%M+x*q.z%M)%M;
		y=(y*q.x%M+x*q.y%M)%M;
		x=x*q.x%M;
	}
	void up(int q){
		if(q<i){
			x=(x+z)%M,z=0;
			i=q;
		}
	}
};
vector<int>g[200005];
map<int,T>q[200005];
void dfs(int v,int d){
	dp[v]=d;
	s[d]++;
	for(int i=0;i<g[v].size();i++)dfs(g[v][i],d+1);
}
void merge(int x,int y,int i){
	if(q[b[x]].size()<q[b[y]].size())swap(x,y);
	ll w=b[y];
	x=b[x],b[y]=x;
	auto it=q[w].begin();
	while(it!=q[w].end()){
		it->S.up(i);
		if(q[x].find(it->F)!=q[x].end()){
			q[x][it->F].up(i);
			q[x][it->F].plus(it->S);
		}else q[x].insert(*it);
		it++;
	}
}
void dfs2(int v){
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		dfs2(u);
		merge(v,u,dp[v]);
	}
}
int main(void){
    scanf("%lld",&n);
    n++;
    z[0]=1;
    for(int i=1;i<=n;i++)z[i]=z[i-1]*2LL%M;
    for(int i=1;i<n;i++){
		ll p;
		scanf("%lld",&p);
		g[p].PB(i);
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		b[i]=i;
		q[i].insert(pair<int,T>(dp[i],T{1,1,0,dp[i]}));
	}
	dfs2(0);
	for(auto it=q[b[0]].begin();it!=q[b[0]].end();it++){
		ans=(ans+(it->S.y)*z[n-s[it->F]])%M;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 70528
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [a,b,c,d] = nextStrArray().map(val => BigInt(val))
    let ac = a*c
    let ad = a*d
    let bc = b*c
    let bd = b*d
    let ans = -10000000000000000000
    if(a<=0n && b >= 0n || c<=0n && d >=0n){
        if(ans < ac) ans = ac
        if(ans < ad) ans = ad
        if(ans < bc) ans = bc
        if(ans < bd) ans = bd
        if(ans < 0) ans = 0n
    } else {
        if(ans < ac) ans = ac
        if(ans < ad) ans = ad
        if(ans < bc) ans = bc
        if(ans < bd) ans = bd
    }
    console.log(String(ans))
}
Main()



Measured memory_bytes: 29680
# t = "abcdefghijklmnopqrstuvwxyz"
s = input()
t = set(list(s))
ans = 1000
for i in t:
    S = s
    c = 0
    while len(set(S))!=1:
        c+=1
        ts = ""
        for  j,k in zip(S,S[1:]):
            if j == i or k == i:
                ts+=i
            else:
                ts+=k
        S = ts
    ans = min(ans,c)
    # print(c)

print(ans)




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

int n;
long x, dp[51];

long a(int n){return (1L << (n+2)) - 3;}
long b(int n){return (1L << (n+1)) - 1;}

long dps(int n, long x){
	if (x >= a(n)) return b(n);
	else if (x == 1) return 0;
	else if (1 < x && x <= a(n-1)+1) return dps(n-1, x-1);
	else if (x == a(n-1)+2) return b(n-1) + 1;
	else return b(n-1) + dps(n-1, x-a(n-1)-2) + 1;
}

int main(){
	cin >> n >> x;
	cout << dps(n, x);
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) i, n, ans
  character(2*10**5) S, T
  read(*, *) S
  read(*, *) T
  !read(*, *) (L(i), i = 1,N)
  n = len(trim(S))
  ans = n
  do i = 1, n
    if (S(i:i) == T(i:i)) then
      ans = ans-1
    endif
  enddo
  write(*, *) ans
end program main


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)

// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < n; ++i){
// 		res += max(0ll, a[i]-x/f[i]);
//     }
//     return res <= k;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main(){
  ll x, y;
  cin >> x >> y;
  ll ans = 10e10;
  if(x <= y) ans = min(ans, y - x);
  if(-x <= y) ans = min(ans, y + x + 1);
  if(x <= - y) ans = min(ans, -y - x + 1);
  if(-x <= -y) ans = min(ans, - y + x + 2);
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define DEBUG 0
using namespace std;

int main()
{
    #if DEBUG
    freopen("test.txt","r",stdin);
    #endif // DEBUG
    int buf[100000];
    int N;
    scanf("%d", &N);
    for(int i=0;i<N;i++)
    {
        scanf("%d", &buf[i]);
    }

    sort(buf, buf+N);//排序后，nlogn
    //获得所有奇数的数量
    int countN = 0;
    int temp = 1;//统计数字重复次数
    for(int i=0; i<N; i++)
    {
        if(buf[i]==buf[i+1])
        {
            temp++;
            continue;
        }
        else
        {
            if(temp%2!=0){
                countN++;
            }
            temp = 1;//还原
        }
    }
    printf("%d", countN);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
//#include <pair>

using namespace std;

using lint = long long;

int main(void)
{
	int N;
	cin >> N;
	vector<pair<int, int>> vp(N);
	for (int i = 0; i < N; i++){
		cin >> vp[i].second >> vp[i].first;
	}
	sort(vp.begin(), vp.end());

	int times = 0;
	for (int i = 0; i < N; i++){
		times += vp[i].second;
		if (times > vp[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a == 1) a = 14;
  if(b == 1) b = 14;
  
  if(a < b) cout << "Bob" << endl;
  else if(a == b) cout << "Draw" << endl;
  else cout << "Alice" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define t_case ll test;cin>>test;while(test--)
#define left(nod) 2*nod
#define right(nod) 2*nod+1
#define ss second
#define ff first
#define pb push_back
#define pll pair<ll,ll>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deb(a) cout<<#a<<": "<<a;cout<<endl;
#define deba(a) cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;


int main()
{
	FAST;
	ll x;cin>>x;
	if(x>=30)cout<<"Yes";
	else cout<<"No";
	
	
}


Measured memory_bytes: 3644
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var a = nexts(n);
  var ans = 0, mx = 0;
  for(var i = 0; i < n; i++){
    ans += Math.max(0, mx-a[i]);
    mx = Math.max(mx,a[i]);
  }
  return ans;
}

Measured memory_bytes: 55472
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute11_1();
	}
	
	private static void execute11_1() {
		try (Scanner sc = new Scanner(System.in)) {
			long n = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();
			
			long ans =0;
			if((b-a)%2!=0) {
				
				if(a-1>n-b) {
					long r = n-b+1;
					a+=r;
					b=n;
					ans=r+(b-a)/2;
				} else {
					long r = a;
					b-=r;
					a=1;
					ans=r+(b-a)/2;
				}
				
			} else {
				ans = (b-a)/2;
			}
			
			System.out.println(ans);
		}
		
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
        int w;
        cin >> w;
        int count = 0;
        while(w){
                count++;
                int n;
                cin >> n;
                int list[n][2];
                for(int i = 0; i < n; i++){
                        scanf("%d,%d", &list[i][0],&list[i][1]);
                }   
                int c[n+1][w+1];
                for(int i = 0; i < n+1; i++){
                        c[i][0] = 0;
                }   
                for(int i = 0; i < w+1; i++){
                        c[0][i] = 0;
                }   
                for(int i = 1; i < n+1; i++){
                        for(int j = 1; j < w+1; j++){
                                if(list[i-1][1] <= j){ 
                                        c[i][j] = max(c[i-1][j], c[i-1][j-list[i-1][1]]+list[i-1][0]);
                                }else{
                                        c[i][j] = c[i-1][j];
                                }   
                        }   
                }   
                int p = 0;
                int _w = 0;
                for(int i = 1; i <= w; i++){
                        if(c[n][i-1] < c[n][i]){
                                p = c[n][i];
                                _w = i;
                        }   
                }   
                cout << "Case " << count << ":" << endl << p << endl << _w << endl;
                cin >> w;
        }   
}

Measured memory_bytes: 0
//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

int n, a[N], r0, r1;
int h[2][N], ans;
vector<int> adj[N];

void dfs(int v = 0, int par = -1, int f = 0) {
	for (int u : adj[v]) 
		if (u != par) {
			h[f][u] = h[f][v] + 1;
			dfs(u, v, f);
		}
}

int main() {
	cin >> n >> r0 >> r1;
	r0--, r1--;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(r0, -1, 0);
	dfs(r1, -1, 1);
	for (int i = 0; i < n; i++)
		if (h[1][i] < h[0][i])
			continue;
		else {
			int t = h[1][i] - h[0][i];
			ans = max(ans, h[1][i] - 1);
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12928
n ,m = map(int, input().split())
l = set()
r = set()
for i in range(m):
  li ,ri = map(int, input().split())
  l.add(li)
  r.add(ri)
r.add(n)
lm = max(l)
rm = min(r)
if lm > rm:
  ans = 0
else:
  ans = rm-lm+1
print(ans)

Measured memory_bytes: 18784
#include <iostream>

int main() {

    int x, y;

    for ( ;; ) {

        std::cin >> x >> y;
        if ( x > y ) std::swap(x, y);

        if ( y == 0 ) break;

        std::cout << x << " " << y << std::endl;
    }


    return 0;
}



Measured memory_bytes: 3016
#include <iostream>
using namespace std;
 
int main() {
	 string s;
   string t;
   cin>>s>>t;
   int z, valasz=0;
   z=s.size();
   for(int sz=0;z>sz;sz++){
    if(s[sz]!=t[sz]){
        valasz++;
    }
   }  
   cout<<valasz; 
}


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

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    int ans=0;
    for(int i=0; i<(1<<h); ++i){
        for(int j=0; j<(1<<w); ++j){
            vector<string>t(h);
            rep(i,h)t[i]=s[i];
            rep(a,h){
                if(i&(1<<a)){
                    rep(b,w)t[a][b]='.';
                }
            }
            rep(a,w){
                if(j&(1<<a)){
                    rep(b,h)t[b][a]='.';
                }
            }
            int cnt=0;
            rep(a,h)rep(b,w)if(t[a][b]=='#')cnt++;
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define num(a) a-'0'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int rc=0,rw=0;
	int l=s.length();
	rep(i,0,l){
		if(s[i]=='R'){
			rc++;
		}
		else{
			rw++;
		}
	}
	int ans=0;
	rep(i,0,rc){
		if(s[i]=='W'){
			ans++;
		}
	}
	cout<<ans<<ln;
}	

int main(){
	boost_io;
	cout<<setprecision(10);
	solve();
	return 0;
}


Measured memory_bytes: 3772
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const INPUT = fs.readFileSync('/dev/stdin', 'utf-8');
const N = +INPUT.split('\n')[0].split(' ')[0];
const K = +INPUT.split('\n')[0].split(' ')[1];
const R = +INPUT.split('\n')[1].split(' ')[0];
const S = +INPUT.split('\n')[1].split(' ')[1];
const P = +INPUT.split('\n')[1].split(' ')[2];
const T = INPUT.split('\n')[2].split(' ')[0].split('');
// とにかく勝ち続ければ良い
let score = 0;
for (let n = 0; n < N; n++) {
    if (n >= K && T[n - K] === T[n]) {
        T[n] = '-';
        continue;
    }
    if (T[n] === 'r') {
        score += P;
    }
    else if (T[n] === 's') {
        score += R;
    }
    else {
        score += S;
    }
}
console.log(score);


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

int main()
{
	char s[105];
	scanf("%s",s);
	int i=-1, j=strlen(s), cnt=0;
	while (++i<--j)
		if (s[i]!=s[j])
			cnt++;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Miguel Mini
 */

#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define set_to(x, v) fill(all(x), v)
#define eb emplace_back
#define lso(x) ((x)&-(x))
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int maxn = 1e5 + 10;
int mod = 1e9 + 7;
int n;
vi g[maxn];
int dp[maxn];

int add(int a, int b) {
    return (a + b) % mod;
}

int mul(ll a, ll b) {
    return a * b % mod;
}

vi L[maxn];
vi R[maxn];
void dfs(int x, int p) {
    for (int v : g[x]) {
        if (v == p) continue;
        dfs(v, x);
    }
    int m = sz(g[x]);
    L[x].resize(m);
    R[x].resize(m);
    for (int i = 0; i < m; ++i) {
        int v = g[x][i];
        if (i == 0) L[x][i] = v == p ? 1 : add(1, dp[v]);
        else L[x][i] = mul(L[x][i-1], v == p ? 1 : add(1, dp[v]));
    }
    for (int i = m-1; i >= 0; --i) {
        int v = g[x][i];
        if (i == m-1) R[x][i] = v == p ? 1 : add(1, dp[v]);
        else R[x][i] = mul(R[x][i+1], v == p ? 1 : add(1, dp[v]));
    }
    dp[x] = L[x][m-1];
}

void dfs_reroot(int x, int p, int id, int temp = 1) {
    if (p != 0) {
        dp[x] = mul(dp[x], temp = add(1, mul(temp, mul(id == 0 ? 1 : L[p][id-1], id == sz(g[p]) - 1 ? 1 : R[p][id+1]))));
    }
    re(i, 0, sz(g[x])) {
        int v = g[x][i];
        if (v == p) continue;
        dfs_reroot(v, x, i, temp);
    }
}

class VSubtree {
public:

    void solveOne(istream& in, ostream& out) {
        in >> n >> mod;
        if (n == 1) {
            out << 1 << endl;
            return;
        }
        re(i, 1, n+1) {
            g[i].clear();
            L[i].clear();
            R[i].clear();
        }
        re(i, 1, n) {
            int a, b;
            in >> a >> b;
            g[a].eb(b);
            g[b].eb(a);
        }
        dfs(1, 0);
        dfs_reroot(1, 0, 0);
        re(i, 1, n+1) {
            out << dp[i] << endl;
        }
    }

    void solve(istream& in, ostream& out) {
        int testNumber = 1;
        //in >> testNumber;
        re(tc, 1, testNumber+1) {
            //out << "Case #" << tc << ": ";
            solveOne(in, out);
        }
    }
};


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	VSubtree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

//	modNの計算をするクラス
template <int mod> struct mint {
    int data;
    mint( void ) :data(0) {}
    mint( int n ) :data( n>=0 ? n%mod : (mod - (-n)%mod) %mod ) {}
    operator int() { return data; }
    friend istream &operator>>(istream&is,mint&m){int n; is>>n; m=n; return is;}
    friend ostream &operator<<(ostream&os,mint&m){os<<(int)m; return os;}
    mint operator+ ( int n ) { return (data + n) % mod; }
    mint operator+ (mint m ) { return *this + (int)m; }
    void operator+=( int n ) { data = *this +      n; }
    void operator+=(mint m ) { data = *this + (int)m; }
    mint operator* ( int n ) { return (lint)data * n % mod; }
    mint operator* (mint m ) { return *this * (int)m; }
    void operator*=( int n ) { data = *this *      n; }
    void operator*=(mint m ) { data = *this * (int)m; }
    mint operator/ ( int n ) { return *this * mint(n).inv(); }
    mint operator/ (mint m ) { return *this * m.inv(); }
    void operator/=( int n ) { data = data * mint(n).inv(); }
    void operator/=(mint m ) { data = data * m.inv(); }
    bool operator==( int n ) { return data == n; }
    bool operator==(mint m ) { return data == m.data; }
    bool operator!=( int n ) { return data != n; }
    bool operator!=(mint m ) { return data != m.data; }
    mint pow(int n){mint a=1,b=data;while(n>0){if(n&1)a*=b;b*=b;n>>=1;}return a;}
    mint pow(mint m){ return (*this).pow((int)m); }
    mint inv(){int a=data,b=mod,c=1,d=0,e;while(b){e=a/b;swap(a-=e*b,b);swap(c-=e*d,d);}return c;}
};
using mint_7 = mint<1000000007>;

mint_7 fact( mint_7 n ) {
    return n == 1 ? mint_7(1) : fact( n-1 ) * n;
}

int main() { cin.tie(0); ios::sync_with_stdio(false);
    mint_7 N = in, M = in;

    if( abs(N-M) > 1 ) {
        cout << "0\n";
    } else if( N == M ) {
        cout << fact(N) * fact(M) * 2 << "\n";
    } else {
        cout << fact(N) * fact(M) << "\n";
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  int x;
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = N - 1; i >= 0; i--) {
    int n = N / (i + 1);
    int count = 0;
    if (n > 1) {
    for (int j = 1; j < n; j++) {
     if (b.at((i + 1) * (j + 1) - 1) == 1) {
       count++;
     }
    }
    }
    count = count % 2;
    if (count != a.at(i)) {
      b.at(i) = 1;
      x++;
    }
  }
  if (x == 0) {
    cout << 0 <<endl;
  }
  else {
    cout << x <<endl;
    for (int i = 0; i < N; i++) {
      if (i != N -1 ) {
        if (b.at(i) == 1) {
        cout << i + 1 << " ";
        }
      }
      else {
        if (b.at(i) == 1) {
        cout << i + 1 <<endl;
        }
        else {
        cout <<endl;
        }
      }
    }
  }
}

Measured memory_bytes: 2432
while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

    cnt = 0
    ave = x / 3
    for i in ( 1 .. ave-1 )
    	ave2 = (x-i) / 2
        for j in ( i+1 .. ave2 )
        	k = x-i-j
        	if j < k && k <= n
                cnt += 1
            end
        end
    end
 
    puts( cnt )
end

Measured memory_bytes: 6112
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18

def ddprint(x):
  if DBG:
    print(x)

def cover0(c,d):
    m = len(c)
    for i in range(m):
        if c[i]==0:
            continue
        k = -1
        for j in range(62):
            b = 1<<j
            if c[i]&b != 0:
                k = j
                break
        for j in range(i+1,m):
            if c[j]&b != 0:
                c[j] ^= c[i]
        for j in range(len(d)):
            if d[j]&b != 0:
                d[j] ^= c[i]
    return sum(d)==0

t = inn()
for tt in range(t):
    n = inn()
    a = inl()
    s = ins()
    top = n
    to0 = []
    to1 = []
    done = False
    while top>0:
        prev0 = top
        while top>0 and s[top-1]=='0':
            top -= 1
        top0 = top
        to0.extend(a[top0:prev0])
        prev1 = top
        while top>0 and s[top-1]=='1':
            top -= 1
        top1 = top
        to1.extend(a[top1:prev1])
        cc = [x for x in to0]
        dd = [x for x in to1]
        if not cover0(cc,dd):
            print(1)
            done = True
            break
    if not done:
        print(0)


Measured memory_bytes: 70084
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int n, m;
	cin>>n>>m;
	vector<ll> p(n - 1, 0);
	vector<ll> l(n - 1);
	REP(i, n - 1) cin>>l[i];
	ll nc = 0;
	REP(i, m) {
		ll a;
		cin>>a;
		if(a > 0) {
			p[nc] += 1;
			if(nc + a < n - 1) p[nc + a] += -1;
		} else {
			if(nc < n - 1)p[nc] += -1;
			p[nc + a] += 1;
		}
		nc = nc + a;
	}
	FOR(i, 1, n - 1) {
		p[i] += p[i - 1];
	}
	ll ans = 0;
	REP(i, n - 1) {
		ans += p[i] * l[i];
		ans = ans % 100000;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4356
N,M,Q = map(int,input().split())
L = list(range(1,M+1))
X = list()
for i in range(Q):
  X.append(list(map(int,input().split())))
  
ans = 0

import itertools
for l in itertools.combinations_with_replacement(L, N):
  l = sorted(list(l))
  s = 0
  for a,b,c,d in X:
    if l[b-1]-l[a-1]==c:
      s += d
  if ans < s:
    ans = s

print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
using Graph = vector<VE>;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	COMinit();
	int n, k; cin >> n >> k;
	rep(i, k) {
		cout << (COM(n - k + 1, i + 1)*COM(k-1, i))%MOD << endl;
	}
	return 0;
}

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

#define MAX 101

typedef struct {
    int array[101]; // 0番目は使わない
    int top; // 常に要素数に一致
} Stack;

Stack S;

void initialize(void) {
    S.top = 0;
}

int isEmpty(void) {
    return S.top == 0;
}

int isFull(void) {
    return S.top >= MAX - 1;
}

void push(int x) {
    if (isFull()) {
        printf("Stack overflow\n");
        exit(0);
    } else {
        S.top++;
        S.array[S.top] = x;
    }
}

int pop() {
    if (isEmpty()) {
        printf("Stack underflow\n");
        exit(0);
    } else {
        S.top--;
        return S.array[S.top+1];
    }
}

int main(void) {
    int x;
    char s[100];
    initialize();
    while( scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) {
            int y = pop();
            int x = pop();
            push(x + y);
        } else if ( s[0] == '-' ) {
            int y = pop();
            int x = pop();
            push(x - y);
        } else if ( s[0] == '*' ) {
            int y = pop();
            int x = pop();
            push(x * y);
        } else  {
            x = atoi(s);
            push(x);
        }
    }
    printf("%d\n", pop());
    return 0;
}



Measured memory_bytes: 1928
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

bool cmp(const vector<ll> &x, vector<ll> &y)
{
  return x[1] == y[1] ? x[2] < y[2] : x[1] < y[1];
}

int main()
{
  int n, t, a, x, l;
  cin >> n;
  vector<double> h(n);
  double min = 100000;

  cin >> t >> a;

  for (int i = 0; i<n; i++)
  {
    cin >> x;
    if (min > fabs(t-x*0.006-a))
    {
      min = fabs(t-x*0.006-a);
      l = i+1;
    }
  }

  cout << l << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    cin >> n;
    for(i=0;i<s.size();i+=n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    static final int MODULUS = 1_000_000_007;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(H, W, A, B));

        sc.close();
    }

    static int solve(int H, int W, int A, int B) {
        int leftWayNum = 1;

        int rightWayNum = 1;
        for (int i = 0; i < H - 1; ++i) {
            rightWayNum = multiplyMod(rightWayNum, multiplyMod(H + W - B - 2 - i, invMod(i + 1)));
        }

        int result = 0;
        for (int i = 0; i < H - A; ++i) {
            result = addMod(result, multiplyMod(leftWayNum, rightWayNum));

            leftWayNum = multiplyMod(leftWayNum, multiplyMod(B + i, invMod(i + 1)));
            rightWayNum = multiplyMod(rightWayNum, multiplyMod(H - i - 1, invMod(H + W - B - 2 - i)));
        }

        return result;
    }

    static int invMod(int x) {
        return BigInteger.valueOf(x).modInverse(BigInteger.valueOf(MODULUS)).intValue();
    }

    static int addMod(int x, int y) {
        return (x + y) % MODULUS;
    }

    static int multiplyMod(int x, int y) {
        return (int) ((long) x * y % MODULUS);
    }
}

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

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

int main() { 
    int D, T, S;
    cin >> D >> T >> S;
    if ( D/(S*1.0) <= T) {
        // cout << D/(S*1.0) << endl;
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> A(N), B(N + 1);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    sort(A.begin(), A.end(), greater<>());
    partial_sum(A.begin(), A.end(), B.begin() + 1);
    unsigned long ans{0}, c{0};
    const auto& calc = [&M, &A, &B, &ans, &c](unsigned long X) -> bool {
        unsigned long cnt{0}, val{0};
        for(const auto& i : A){
            auto dif = upper_bound(A.begin(), A.end(), X - min(X, i), greater<>()) - A.begin();
            cnt += dif;
            val += B[dif] + i * dif;
        }
        if(cnt <= M){
            ans = val;
            c = cnt;
        }
        return cnt <= M;
    };
    unsigned long L{2 * A.back()}, R{2 * A[0] + 1};
    while(L + 1 < R){
        auto m = (L + R) / 2;
        (calc(m) ? R : L) = m;
    }
    cout << ans + L * (M - c) << endl;
    return 0;
}

Measured memory_bytes: 1792
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

n = inp[0]
a = [0]+inp
t = na(n+1,0)
ans = []
((n/2+1)..n).each do |i|
  if(1 == a[i])
    t[i] = 1
    ans.push(i)
  end
end
(1..(n/2)).reverse_each do |i|
  d = i*(n/i)
  c = 0
  while d > 0
    c ^= t[d]
    if(d != i)
      d -= i
      next
    end
    if(c != a[i])
      t[i] = 1
      ans.push(i)
    end
    d -= i
  end
end
puts ans.size
puts ans.join(" ") if(ans.size > 0)

Measured memory_bytes: 24724
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	string s1,s2;
	cin>>s1>>s2;
	string s3=s1+s2;
	int a=stoi(s3);
	if(a%(int)sqrt(a)==0)cout<<"Yes";
	else cout<<"No";
	return 0;

//   TimeTaken();
}


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

string solve(string s, int K)
{
    for (auto& c : s) if (c != 'a')
    {
        const auto needed = 'z'-c+1;
        if (K >= needed)
        {
            K -= needed;
            c = 'a';
        }
    }

    s.back() = char(s.back() + K%26);

    return s;
}

int main()
{
    string s; cin >> s;
    int K; cin >> K;
    cout << solve(move(s), K) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N; cin >> N;

  ll sum = 0;
  vector<ll> ans;
  ll cnt = 1;
  
  while(sum < N){
    sum += cnt;
    ans.pb(cnt);
    cnt++;
  }

  if(sum == N){
    rep(i,ans.size()){
      cout << ans[i] << endl;
    }
    return 0;
  }
  else{
    ll mi = sum -N;
    rep(i,ans.size()){
      if(ans[i] == mi) continue;
      cout << ans[i] << endl;
    }
  }
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

if (sum(a)/n)%1 < 0.5:
    avr = sum(a)//n
else:
    avr = sum(a)//n+1

ans = 0
for i in a:
    ans += (i-avr)**2

print(ans)

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N, Q;
string S;
int l[110000], r[110000];
int imos[110000];
signed main() {
    cin >> N >> Q;
    cin >> S;
    for (int i = 0; i < Q; i++) { cin >> l[i] >> r[i]; }
    for (int i = 1; i < N; i++) {
        imos[i] = imos[i - 1];
        if (S[i - 1] == 'A' && S[i] == 'C') { imos[i]++; }
    }
    for (int i = 0; i < Q; i++) { cout << imos[r[i] - 1] - imos[l[i] - 1] << endl; }
}


Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main()
{
    char b ;
    cin >> b ;
    if( b == 'A')
    {
       cout <<'T'<< endl;
    }
    {
        if( b == 'T')
        {
            cout <<'A'<< endl;
        }
        if( b == 'G')
        {
            cout <<'C'<< endl;
        }
        {
            if( b == 'C')
            {
                cout << 'G' << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
    vector<int> par;
    int cnt;
    UnionFind(int N):par(N,-1),cnt(N){}
    void init(int N){par.assign(N,-1);}
    int root(int x){
        if(par[x]<0)return x;
        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);
        par[x]+=par[y];
        par[y]=x;
        cnt--;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};
struct Edge{
    double a,b,cost;
    bool operator<(const Edge &o){
        return cost<o.cost;
    }
};
int main(){
    int n;scanf("%d",&n);
    vector<pair<int,int>> x(n),y(n);
    map<pair<int,int>,int> m;
    for(int i=0;i<n;i++){
        scanf("%d%d",&x[i].first,&y[i].first);
        x[i].second=y[i].second=i;
    }
    vector<Edge> a;
    sort(x.begin(),x.end()),sort(y.begin(),y.end());
    for(int i=0;i<n-1;i++){
        Edge ne;
        ne.a=x[i].second,ne.b=x[i+1].second,ne.cost=x[i+1].first-x[i].first;
        a.push_back(ne);
        ne.a=y[i].second,ne.b=y[i+1].second,ne.cost=y[i+1].first-y[i].first;
        a.push_back(ne);
    }
    sort(a.begin(),a.end());
    int ans=0;
    UnionFind Tree(n);
    for(auto na:a){
        if(Tree.issame(na.a,na.b))continue;
        ans+=na.cost;
        Tree.merge(na.a,na.b);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 10096
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
boolean ans=false;
int temp=0;
int A=Integer.parseInt(sc.next());
int B=Integer.parseInt(sc.next());
if(A>8||B>8){System.out.println(":(");}else{System.out.println("Yay!");}
}
}

Measured memory_bytes: 21844
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N, M;
  sc.scan(N, M);

  int[] A = new int[N];
  int[] B = new int[N];
  foreach (i; 0 .. N)
    sc.scan(A[i], B[i]);

  sort(zip(A, B));
  long res = 0;

  int i = 0;
  while (M > 0) {
    foreach (j; 0 .. B[i]) {
      res += A[i];
      M--;
      if (M == 0)
        break;
    }
    i++;
  }
  writeln(res);
}


Measured memory_bytes: 3964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n*2);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 24860
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextInt();
		long b = scan.nextInt();
		
		if(a > 0 && b > 0){
			System.out.println("Positive");
		}else if(a * b <= 0){
			System.out.println("Zero");
		}else{
			long sum = a + b;
			if(sum * -1 % 2 == 1){
				System.out.println("Positive");
			}else{
				System.out.println("Negative");
			}
		}
	}
}

Measured memory_bytes: 9552
n,a,b,c,d=map(int,input().split())
array=[]
if n%a!=0:
    array+=[(n//a+1)*b]
else:array+=[int((n/a)*b)]
if n%c!=0:
    array+=[(n//c+1)*d]
else:array+=[int((n/c)*d)]
print(min(array))


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> ps(n);
  for(int i=0;i<n;i++) cin>>ps[i],ps[i]--;

  vector< vector<int> > G(n);
  for(int i=0;i<n;i++)
    G[ps[i]].emplace_back(i);

  for(int add=0;add<=1;add++){
    int r=0;
    for(int i=0;i<n;i++) r=ps[r];

    set<int> ls;
    {
      int l=r;
      do{
        ls.emplace(l);
        l=ps[l];
      }while(l!=r);
    }

    vector< set<int> > H(n);
    vector<int> dp(n,0);
    int l=r;
    do{
      MFP([&](auto dfs,int v)->int{
            for(int u:G[v]){
              if(ls.count(u)){
                if(l!=r) H[v].emplace(dp[u]);
                continue;
              }
              H[v].emplace(dfs(u));
            }
            int &res=dp[v];
            while(H[v].count(res)) res++;
            return res;
          })(l);

      if(l==r&&add){
        H[l].emplace(dp[l]);
        int &res=dp[l];
        while(H[l].count(res)) res++;
      }

      l=ps[l];
    }while(l!=r);

    int flg=1;
    for(int v=0;v<n;v++){
      set<int> ss;
      for(int u:G[v])
        ss.emplace(dp[u]);
      int res=0;
      while(ss.count(res)) res++;
      flg&=dp[v]==res;
    }
    if(flg) drop("POSSIBLE");
  }

  drop("IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 37248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);

            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];

            var ans = Math.Min(N*A,B);

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define lol(i,n) for(int i=0;i<n;i++)
using namespace std;
int d[1010][1010],h,w,a;
int main(){
    while(cin>>h>>w>>a&&h){
    int x=0,y=0;
    memset(d,0,sizeof(d));
    d[0][0]=a;
    lol(i,h)lol(j,w){
	cin>>a;
	d[i+1][j]+=d[i][j]/2+d[i][j]%2*(1-a);
	d[i][j+1]+=d[i][j]/2+d[i][j]%2*a;
	d[i][j]+=a;
    }
    while(x<w&&y<h){
	if(d[y][x]%2)y++;
	else x++;
    }
    cout<<y+1<<" "<<x+1<<endl;
    }
    return 0;
}



Measured memory_bytes: 7064