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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

   string ans = "~";
   for (int i = 0; i <= n-m; i++) {
      bool ok = true;
      string s2 = s;
      for (int j = 0; j < m; j++) {
         if (s[i+j] != '?' && s[i+j] != t[j]) {
            ok = false;
         }
         s2[i+j] = t[j];
      }
      if (ok) {
         replace(s2.begin(), s2.end(), '?', 'a');
         ans = min(ans, s2);
      }
   }

   if (ans == "~") {
      cout << "UNRESTORABLE" << endl;
   } else {
      cout << ans << endl;
   }

   return 0;
}

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

int main(void)
{
    int a,b;
    char op;
    
    while(1){
        scanf("%d%*c%c%d",&a,&op,&b);
        
        if(op!='?'){
            if(op=='+'){
                printf("%d\n",a+b);
            }else if(op=='-'){
                printf("%d\n",a-b);
            }else if(op=='*'){
                printf("%d\n",a*b);
            }else if(op=='/'){
                printf("%d\n",a/b);
            }
        }else{break;}
        
    }
    return 0;
}


Measured memory_bytes: 2112
#include <cstdio>

using namespace std;

int main()
{
  int x, y, r, hisi = 0, tyou = 0;
  while (scanf("%d,%d,%d ", &x, &y, &r) == 3) {
    if (x == y) {hisi++;}
    if (x * x + y * y == r * r) {tyou++;}
  }
  
  printf("%d\n%d\n", tyou, hisi);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;

int main() {
	FAST;

	ll n,m,d;
	cin>>n>>m>>d;
	double ans;
	if(n==1)
		ans=m-1;
	else
	{
		ans=(m-1)*1.0/n;
		if(d!=0)
			ans=ans*(2.0/n)*(n-d);	
	}
	printf("%.10lf",ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

int N, M;
int as[100000];
vector<pair<int, int>> bs;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        as[i] = a;
        bs.emplace_back(b, a);
    }
    sort(as, as + M);
    sort(bs.begin(), bs.end());

    int ans = 0;
    int *ap = as;
    int last_cut = -1;
    for (int i = 0; i < M; i++) {
        if (bs[i].second < last_cut) continue;
        int *apn = upper_bound(ap, as + M, bs[i].first - 1);
        if (apn > ap) {
            ans++;
            ap = apn;
            last_cut = bs[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1656
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

int main(){
	int w, d;
	while(scanf("%d%d", &w, &d), d != 0){
		vector<int> a(w + 1), b(d + 1);
		for(int i = 0; i < w; ++i){
			scanf("%d", &a[i]);
		}
		for(int i = 0; i < d; ++i){
			scanf("%d", &b[i]);
		}
		sort(a.begin(), a.end(), greater<int>());
		sort(b.begin(), b.end(), greater<int>());

		int t = 0, u = 0;
		int ans = 0;
		while(a[t] || b[u]){
			if(a[t] == b[u]){
				ans += a[t];
				++t;
				++u;
			}
			else if(a[t] > b[u]){
				ans += a[t];
				++t;
			}
			else{
				ans += b[u];
				++u;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1048
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

signed main(void){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) <<"\r\n";
  return 0;
}


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


int main(){
    ll n;cin>>n;
    priority_queue<ll,vector<ll>,greater<ll> > a;
    ll a1;
    ll ans=n;
    rep(i,n){
        cin>>a1;
        a.push(a1);
    }
    while(1<a.size()){
        ll b = a.top();a.pop();
        ll b1 = a.top();a.pop();
        if(2*b<b1){
            a.push(b+b1);
            ans=a.size();
        }
        else{
            a.push(b+b1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
def solve():

    N = int(input())

    prots = []

    for _ in range(N):
        x, y, h = map(int, input().split())
        prots.append([h, x, y])

    # 高さ０をモデルケースにしない
    prots.sort(reverse=True)

    for centerx in range(101):
        for centery in range(101):
            h, x, y = prots[0]
            # 仮置
            H = h+abs(centerx - x) + abs(centery - y)
            flag = True
            for i in range(N):
                h, x, y = prots[i]
                if h != max(0, H-abs(centerx - x) - abs(centery - y)):
                    flag = False
                    break
            if flag:
                print(centerx, centery, H)
                exit()


if __name__ == "__main__":
    solve()


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;
    vector<LL> a(3*n);
    REP(i,3*n){
        cin>>a[i];
    }
    sort(ALL(a), greater<LL>());
    
    LL result = 0;
    REP(i,n){
        result += a[i*2+1];
    }

    cout<<result<<endl;
	return;
}

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

Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define gc getchar()
#define mp make_pair
#define fir first
#define sec second
#define N 200010
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
inline int inn()
{
    int x,ch;while((ch=gc)<'0'||ch>'9');
    x=ch^'0';while((ch=gc)>='0'&&ch<='9')
        x=(x<<1)+(x<<3)+(ch^'0');return x;
}
struct segment{
    int l,r,mn,pt;
    segment *ch[2];
}*rt;pii a[N];
inline int push_up(segment* &rt) { return rt->mn=min(rt->ch[0]->mn,rt->ch[1]->mn); }
inline int update_tags(segment* &rt,int v) { return rt->mn+=v,rt->pt+=v; }
inline int push_down(segment* &rt)
{   return update_tags(rt->ch[0],rt->pt),update_tags(rt->ch[1],rt->pt),rt->pt=0;    }
int build(segment* &rt,int l,int r,int x)
{
    rt=new segment,rt->l=l,rt->r=r,rt->pt=0;
    if(l==r) return rt->mn=x-l;int mid=(l+r)>>1;
    build(rt->ch[0],l,mid,x),build(rt->ch[1],mid+1,r,x);
    return push_up(rt);
}
int update(segment* &rt,int s,int t,int v)
{
    if(s>t) return 0;
    int l=rt->l,r=rt->r,mid=(l+r)>>1;
    if(s<=l&&r<=t) return update_tags(rt,v);
    if(rt->pt) push_down(rt);
    if(s<=mid) update(rt->ch[0],s,t,v);
    if(mid<t) update(rt->ch[1],s,t,v);
    return push_up(rt);
}
int main()
{
    int n=inn(),m=inn(),Ans=min(n,m);
    for(int i=1,l,r;i<=n;i++)
        l=inn(),r=inn(),a[i]=mp(l,r);
    sort(a+1,a+n+1),build(rt,1,m+1,m+1);
    for(int l=0,c=0;l<=m;l++)
    {
        while(c<n&&a[c+1].fir<=l)
            c++,update(rt,a[c].sec+1,m+1,1);
        Ans=min(Ans,n-c+l+rt->mn);
    }
    return !printf("%d\n",n-Ans);
}


Measured memory_bytes: 20608
/*
 * N 以下の正の整数の 10 進法での各桁の和の最大値を求めてください。
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            long n = Long.parseLong(sc.next());
            int nLen = String.valueOf(n).length();
            
            // 出力
            if((n+1)%(long)(Math.pow(10, nLen-1))==0){
            	System.out.println(9*(nLen-1) + n/(long)(Math.pow(10, nLen-1)));
            }else{
            	System.out.println(9*(nLen-1) + n/(long)(Math.pow(10, nLen-1)) - 1);
            }
            sc.close();
        }
    }

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		for (int i = x; i < 1000000; i++) {
			if (isPrime(i)) {
				System.out.println(i);
				return;
			}
		}
	}

	static boolean isPrime(int n) {
		if (n == 1)
			return false;

		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    string s;
    cin >> n >> s;
    int m = s.size();
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < n;++j) {
            dp[i+1][j+1] += dp[i][j];
            if (j) (dp[i+1][j-1] += dp[i][j]*2) %= mod;
            else dp[i+1][0] += dp[i][0];
        }
    }
    cout << dp[n][m] << endl;
    // for (int i = 0;i < n+1;++i) p_ary(dp[i],0,n+1,j);
    return 0;
}

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
vector<double> p(3000,0);
int n;
vector<vector<double>>dp(3000, vector<double>(3000, -1));
double totalP(int i, int cnt){
    if(i == n){
        if(cnt > n/2)
        return 1;
        return 0;
    }
    if(dp[i][cnt] != -1)
    return dp[i][cnt];
    else{
        dp[i][cnt] = totalP(i+1, cnt+1) * p[i] +  totalP(i+1, cnt)*(1 - p[i]);
    }
    return dp[i][cnt];
}
int main() {
    
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    if(n==1){
        cout<<p[0];
    }
    else{
    cout<<setprecision(10)<<totalP(0,0);
    }
	return 0;
}

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

using namespace std;

int main(void) {
	int a, b, c;
	string s;
	cin >> a >> b >> c;
	s = "No";
	if (a + b == c || a + c == b || b + c == a) {
		s = "Yes";
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int c[111];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&c[i]);
	sort(c+1,c+n+1);
	int a,b;
	a=0;
	b=0;
	if(n%2==0){
	for(int i=1;i<=n;i++){
	if(i%2!=0)b=b+c[i];
	else a=a+c[i];
	}
	}
	else {
	for(int i=1;i<=n;i++){
	if(i%2==0)b=b+c[i];
	else a=a+c[i];
	}
	}
	printf("%d",a-b);
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
a = LI()

b = 0
for i in range(N):
    b ^= a[i]

print(*[b^a[i] for i in range(N)])


Measured memory_bytes: 114868
#include<bits/stdc++.h>
using namespace std;
/*#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>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n, k;
    cin>>n>>k;
    cout<<n - k + 1;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i > 0; i++)
const int MOD =1e9+7;
    
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << s1[0] << s2[1] << s3[2];
}


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

using namespace std;

map<int,int> H;

int main(){
    int n, q, x;
    long long s=0;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        ++H[x];
        s+=x;
    }
    scanf("%d",&q);
    for(int i=1;i<=q;++i){
        int a, b;
        scanf("%d%d",&a,&b);
        if(H.count(a)!=0&&H[a]!=0){
            s-=1ll*H[a]*a;
            s+=1ll*H[a]*b;
            if(H.count(b)){
                H[b]+=H[a];
            }else{
                H[b]=H[a];
            }
            H[a]=0;
        }
        printf("%lld\n",s);
    }

}


Measured memory_bytes: 7264
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 605
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,dp[maxn][maxn];
char s[maxn][maxn];

inline int sol(int x,int y)
{
	int tmp=min(x,y);
	rep(i,1,tmp-1) if(s[x][y-i]!=s[x-i][y]) return i;
	return tmp;
}

int main()
{
	n=read(); rep(i,1,n) scanf("%s",s[i]+1);
	rep(i,1,n) rep(j,1,n) s[i+n][j]=s[i][j],s[i][j+n]=s[i][j],s[i+n][j+n]=s[i][j];
	n<<=1; int ans=0;
	rep(i,1,n) rep(j,1,n) dp[i][j]=min(dp[i-1][j-1],sol(i,j)-1)+1;
	rep(i,1,n-1) rep(j,1,n-1) ans+=(dp[i][j]>=(n/2)); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    ll n, k; cin >> n >> k;
    VI p(n); rep(i, n) cin >> p[i];

    sort(ALL(p));
    ll ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 

using namespace std;

int main()
{
	int N, M,count,l,h;
	count = 0;
	cin >> N >> M;
	vector<int>a(M);
	vector<int>b(M);
	vector<int>c(N,1);
	l = 1;
	h = N;
	for (int i = 0;i < M;i++) {
		cin >> a.at(i) >> b.at(i);
		
		for (int m = l-1;m < a.at(i)-1;m++) { c.at(m) = 0; }
		for (int n = b.at(i);n < h;n++) { c.at(n) = 0; }
		if (a.at(i) > l) { l = a.at(i); }
		if (b.at(i) < h) { h = b.at(i); }
    }
	for (int k = 0;k < N;k++) {
		if (c.at(k) == 1) { count++; }
	}
	cout << count << endl;

	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> av(n);
	vector<vector<int>> c(32);
	for(int i = 0; i < n; ++i){
		int a;
		cin >> a;
		av[i] = a;
		for (int j = 0; j < 32; ++j) {
			if (a % 2 == 0) {
				c[j].push_back(i);
			}
			a >>= 1;
		}
	}

	for (int i = 0; i < n; ++i) {
		long long ret = 0;
		for (int j = 0; j < 32; ++j) {
			int t = 1;
			if (av[i] % 2 == 0) {
				t = 0;
			}
			if (c[j].size() % 2 == 1) {
				t = (t + 1) % 2;
			}
			av[i] >>= 1;
			ret += t << j;
		}
		cout << ret << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 29800
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
d = [-1] * n
ansum = 0
def stat(array,par):
    return bisect.bisect(array,par)

for i in range(n):
    indexC = stat(c,b[i])
    d[i] = max(0,n-indexC) 
for i in range(n-1):
    d[n-i-2] += d[n-i-1]
for A in a:
    index = stat(b,A)
    if index < n:
        ansum += d[index]
print(ansum)


Measured memory_bytes: 24264
#include <iostream>			// 백준 12840
#include <cstdlib>
using namespace std;

typedef long long int ll;

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

	ll n, k;
	cin >> n >> k;
	n = n % k;
	while (abs(n - k) < n)
		n = abs(n - k);
	cout << n;

	return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var a, b, c int
  fmt.Scan(&a, &b, &c)
  fmt.Println(minInt(b/a, c))
}

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


int main(){
    int n;
    cin >> n;
    rep(i,10){
        rep(j,10){
            if ( i*j == n ){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}

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

int main() {
	
	int N;
	cin >>N;
	
	vector<pair<pair<string, int>, int>> SP(N);
	
	for(int i=0; i<N; i++){
		
		cin >>SP.at(i).first.first;
		SP.at(i).second=i+1;
		
		int t;
		cin >>t;
		
		SP.at(i).first.second=-t;
		
	}
	
	sort(SP.begin(),SP.end());
	
	for(int i=0; i<N; i++){
		
		cout <<SP.at(i).second <<endl;
		
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int res = 1e9;
	for (int i = 0; i < n; i++)
	{
		int tmp = 0;
		while (true)
		{
			if(a[i] % 2 == 1) break;
			a[i] /= 2;
			tmp++;
		}
		res = min(res, tmp);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = 1;
    mp[-1] = 3;
    rep(i, 0, n){
        ans *= mp[a[i] - 1];
        mp[a[i] - 1]--;
        mp[a[i]]++;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int mod = 1e9 + 7;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N], dp[N][2];

vector<ll> v[N];

inline ll add(ll x, ll y){  return  (x % mod + y % mod) % mod;}
inline ll sub(ll x, ll y){  return  (x % mod - y % mod + mod) % mod;}
inline ll mul(ll x, ll y){  x %= mod;   y %= mod;   return 1LL * x * y % mod;}

void dfs(ll u, ll par){
    dp[u][0] = dp[u][1] = 1;
    for(auto i: v[u]){
        if(i != par){
            dfs(i, u);
            dp[u][0] = mul(dp[u][0], dp[i][1]);
            dp[u][1] = mul(dp[u][1], add(dp[i][0], dp[i][1]));
        }
    }
}

void solve(){
    ll n, x, y;
    cin >> n;
    for(int i = 0; i < n - 1; ++i){
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1, 1);
    cout << add(dp[1][0], dp[1][1]);
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 18560
#include <iostream>
using namespace std;
int main() {
    string a;
    string b;

    cin >> a >> b;
    bool g = false;
    bool l = false;
    bool e = false;

    int asize = a.size();
    int bsize = b.size();
    int count = 0;

    if (asize > bsize){
        g = true;
    } else if (asize < bsize){
        l = true;
    } else{
        for (int i = 0; i < asize; ++i) {
            int  ai = a[i];
            int  bi = b[i];
            if (ai > bi)
            {
                g = true;
                break;
            } else if (ai<bi)
            {
                l = true;
                break;
            } else {
                count++;
            }
        }
        if (count == asize){
            e = true;
        }
    }

    if (g == true)cout<<"GREATER";
    if (l == true)cout << "LESS";
    if (e == true)cout<<"EQUAL";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int man[][][] = new int[4][3][10];

		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int v = scan.nextInt();

			man[b-1][f-1][r-1] += v;
		}

		String str = Arrays.stream(man)
			.map(x -> 
				Arrays.stream(x)
					.map( y -> 	" " + Arrays.stream(y).mapToObj(String::valueOf).collect(Collectors.joining(" ")))
					.collect(Collectors.joining("\n"))
			)
			.collect(
					Collectors.joining(
						String.format("\n%s\n", String.join("", Collections.nCopies(20, "#")))
					)
			);
		System.out.println(str);
	}
}



Measured memory_bytes: 33404
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 1000005
using namespace std;  
LL ans=0;
int mkx[M],mky[M],tx,ty,x[M],y[M]; 
vector<int>edge[M];
bool mark[M];
int L,R,E;
void dfs(int x){
	E++;
	if(mark[x])return;
	mark[x]=1;
	if(x<=tx)L++;
	else R++;
	for(int i=0;i<edge[x].size();i++) 
		dfs(edge[x][i]);  
}
int main(){ 
	int n;
	cin>>n; 
	for(int i=1;i<=n;i++){
		scanf("%d %d",&x[i],&y[i]);
		if(!mkx[x[i]])mkx[x[i]]=++tx;
		if(!mky[y[i]])mky[y[i]]=++ty;
	}
	for(int i=1;i<=n;i++){
		int a=mkx[x[i]];
		int b=mky[y[i]]+tx;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	for(int i=1;i<=tx+ty;i++){
		if(!mark[i]){
			L=0,R=0,E=0;
			dfs(i);
			if(L<2||R<2)continue;
			E/=2;
			ans+=1LL*L*R-E;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 40448
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int n;
char s[100005];
int ans[100005];
const int SHEEP=0,WOLF=1;
bool valid(){
	rep(i,n){
		int a=i;
		int b=(i+1)%n;
		int c=(i+2)%n;
		int ox=(s[b]=='x');
		if(ans[b]==WOLF)ox=1-ox;
		if(ans[a]^ox!=ans[c])return false;
	}
	return true;
}
int main(){
	scanf("%d%s",&n,s);
	rep(a,2)rep(b,2){
		ans[0]=a;ans[1]=b;
		for(int i=2;i<n;i++){
			int ox=(s[i-1]=='x');
			if(ans[i-1]==WOLF)ox=1-ox;
			ans[i]=ans[i-2]^ox;
		}
		if(valid()){
			rep(i,n)putchar(ans[i]==SHEEP?'S':'W');
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int i,j;
string s,t;
int main(){
	cin>>s>>t;
	for(i=s.size()-t.size()+1;i>=0;i--){
		if(s[i]==t[0]||s[i]=='?'){
			for(j=0;j<t.size();j++)if(s[i+j]!=t[j]&&s[i+j]!='?')break;
			if(j==t.size()){
				for(j=0;j<t.size();j++)s[i+j]=t[j];
				for(j=0;j<s.size();j++)cout<<(s[j]=='?'?'a':s[j]);
				return 0;
			}
		}
	}
	cout<<"UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

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

  int n, m;
  cin >> n >> m;

  vector<string> grid(n);
  for (auto& e : grid) cin >> e;

  vector<vector<int>> dp(n, vector<int>(m, 0));
  dp[0][0] = 1;

  constexpr long long kMod = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0 && j == 0) continue;
      if (grid[i][j] == '#') continue;

      long long tmp = 0;
      if (i > 0) tmp += dp[i - 1][j];
      if (j > 0) tmp += dp[i][j - 1];
      dp[i][j] = tmp % kMod;
    }
  }
  cout << dp[n - 1][m - 1] << endl;

  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007
#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define nmax 100010

int n, k;
int h[nmax], dp[nmax];

int main()
{
    scanf("%d %d", &n, &k);

    for (int i = 1; i <= n; i++) scanf("%d", &h[i]);

    for (int i = 1; i <= n; i++) dp[i] = INF;

    dp[1] = 0; 

    for (int i = 2; i <= n; i++) {

        for (int j = 1; j <= k; j++)
            if (i - j > 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    printf("%d", dp[n]);

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5 + 10;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

vector<int> g[xx];
vector<int> ans , dp , A;
void dfs(int n , int p) {
  int id = lower_bound(all(dp) , A[n]) - dp.begin();
  int roll_back = dp[id];
  dp[id] = A[n];
  ans[n] = lower_bound(all(dp) , inf) - dp.begin();

  for(auto i : g[n]) {
    if(i != p) {
      dfs(i , n);
    }
  }
  dp[id] = roll_back;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  int N;
  cin >> N;
  ans = A = vector<int>(N);
  dp = vector<int>(N , inf);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i + 1 < N; i++) {
    int u , v;
    cin >> u >> v;
    u-- , v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0 , -1);

  for(int i : ans) {
    cout << i  << "\n";
  }
}

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

a=[]

for i in range(n):
  a.append(int(input()))

ans=0
for i in range(n-1):
  ans+=a[i]//2
  a[i]=a[i]%2
  if a[i]==1 and a[i+1]>=1:
    ans+=1
    a[i]-=1
    a[i+1]-=1
ans+=a[n-1]//2

print(ans)

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

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;

  char c;
  c = S[K-1];

  for(int i=0;i<N;i++){
    if(S[i] != c){
      S[i] = '*';
    }
  }

  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
 
int main() {
    ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	for (int i = (int)s.length() - t.length() ; i >= 0 ; i--) {
		bool y = 0;
		for (int j = 0 ; j < t.length() ; j++) if (s[j + i] != '?' && s[j + i] != t[j]) y = 1;
		if (y == 0) {
            for (int j = 0 ; j < t.length() ; j++) s[j + i] = t[j];
            for (int j = 0 ; j < s.length() ; j++) if (s[j] == '?') s[j] = 'a';
            cout << s;
            return 0;
      	}
	}
	cout << "UNRESTORABLE";
}

Measured memory_bytes: 3640
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if (T.substring(0, S.length()).equals(S)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35356
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>

#define F first
#define S second
 
using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

string s;
string a;

int main () {
	Need_For_Speed();
	cin >> s;
	for (int i = 0; i < s.sz; i++) {
		if (s[i] == 'S') {
			a += 'S';
		}
		else {
			if (a[a.size() - 1] == 'S') {
				a = a.substr(0, a.sz - 1);
			}
			else {
				a += 'T';
			}
		}
	}
	cout << a.sz;
	return 0;
} 

Measured memory_bytes: 1088
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A, B, C = read_int()

Detoxification = C - B - A

res = B + C if Detoxification <= 0 else 2*B + A + 1
print(res)

Measured memory_bytes: 3060
#include <stdio.h>
#define min(x, y) ((x)<(y) ? (x) : (y))
int main(){
  int n;  scanf("%d", &n);
	int ans = 1<<30;
  while(n--){
    int a;  scanf("%d", &a);
    int count = 0;
    while(a % 2 == 0){
      count++;
      a >>= 1;
    }
    ans = min(ans, count);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1704
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <fstream>
#include <cassert>

using namespace std;

const bool online_judge =
#ifdef ONLINE_JUDGE
  true
#else
  false
#endif
  ;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(v)  (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define eb emplace_back
#define SZ(a) ((int)((a).size()))
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,n) for(int i = 1; i <= n; i++)
#define rep3(i,n) for(int i = n-1; i >= 0; i--)
#define tag(i,v) rep(i,SZ(v))
#define _trace(x) #x << " = " << (x)
#define trace(x)  { if(!online_judge) cerr << _trace(x) << endl; }
#define trace2(x,y) { if(!online_judge) cerr << _trace(x) << " " << _trace(y) << endl; }
#define trace3(x,y,z) { if(!online_judge) cerr << _trace(x) << " " << _trace(y) << " " << _trace(z) << endl; }
#define tracev(x) { if(!online_judge) { cerr << #x << " = "; tag(__i, x) { cerr << x[__i] << ","; } cerr << endl; } }
#define fst get<0>
#define snd get<1>
#define thd get<2>
#define divup(x,y) ((x)/(y)+(0<((x)%(y))))
#define mp make_tuple
#define range(x,a,b) ((x) >= (a) && (x) <= (b))

const int inf = 1LL << 60;
int toInt(string s) {int res; stringstream ss; ss<<s; ss>>res; return res; }
string toString(int n) { stringstream ss; ss<<n; return ss.str(); }

int a,b,c,d,e,f;

void run() {

  /* entry point */
  int n;
  while(cin >> n){
    if(n == 0)
      break;
    vs v(n);
    rep(i,n)
      cin >> v[i];

    a = 1;
    b = 2;
    c = 3;
    d = 5;
    e = 4;
    f = 6;

    int ans = 1;
    
    tag(i,v){
      string s = v[i];
      int tmp;
      if(s == "North"){
        tmp = a;
        a = b;
        b = f;
        f = d;
        d = tmp;
      }
      else if(s == "East"){
        tmp = a;
        a = e;
        e = f;
        f = c;
        c = tmp;
      }
      else if(s == "West"){
        tmp = a;
        a = c;
        c = f;
        f = e;
        e = tmp;
      }
      else if(s == "South"){
        tmp = a;
        a = d;
        d = f;
        f = b;
        b = tmp;
      }
      else if(s == "Left"){
        tmp = b;
        b = e;
        e = d;
        d = c;
        c = tmp;
      }
      else if(s == "Right"){
        tmp = b;
        b = c;
        c = d;
        d = e;
        e = tmp;
      }
      else
        assert(false);
      ans += a;
    }

    cout << ans << endl;
  }

}

#undef int

int main(int argc, char *argv[]) {

  #if 0
  if(online_judge){
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
  }
  #endif

  run();

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
const int N=5005,mu=1e9+7;
int g[N],to[N<<1],edge,last[N],Next[N<<1],n,x,y,t[N],siz[N],dp[N][N],inv[N],p[N];
void add(int x,int y){
	to[++edge]=y;
	Next[edge]=last[x];
	last[x]=edge;
}
void dfs(int x,int fa){
	dp[x][1]=1,siz[x]=1;
	for (int i=last[x];i;i=Next[i]){
		int u=to[i];
		if (u==fa) continue;
		dfs(u,x);
		for (int j=0;j<=siz[x]+siz[u];j++) t[j]=0;
		for (int j=1;j<=siz[x];j++)
			for (int k=0;k<=siz[u];k++)
				t[j+k]=(t[j+k]+1ll*dp[x][j]*dp[u][k])%mu;
		siz[x]+=siz[u];
		for (int j=0;j<=siz[x];j++) dp[x][j]=t[j];
	}
	for (int i=2;i<=siz[x];i+=2) dp[x][0]=(dp[x][0]+1ll*(mu-dp[x][i])*g[i]%mu)%mu;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	g[0]=1;
	for (int i=2;i<=n;i+=2) g[i]=1ll*g[i-2]%mu*(i-1)%mu;
	dfs(1,0);
	printf("%d\n",mu-dp[1][0]);
}

Measured memory_bytes: 58328
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
void miti(int,int);
int a,b,n,c,kouzi[17][17];
int main(void)
{
	int x,y,i,k;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0) break;
		scanf("%d",&n);
		for(i=1;i<=b;i++){
			for(k=1;k<=a;k++)	kouzi[i][k]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&x,&y);
			kouzi[y][x]=1;
		}
		c=0;
		miti(1,1);
		printf("%d\n",c);
	}
	return 0;
}
void miti(int p,int o)
{
	if(p==b && o==a)	c++;
	
	else {
		if(o+1<=a && kouzi[p][o+1]==0) miti(p,o+1);
		if(p+1<=b && kouzi[p+1][o]==0) miti(p+1,o);
	}
}

Measured memory_bytes: 2568
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static final String BR = System.getProperty("line.separator");
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			
			StringBuilder s = new StringBuilder();
			String[] strArray;	
			String line = br.readLine();
			
			while(line.equals("0 0") == false){	
				strArray = line.split("\\s");
				for (int i = 0; i < Integer.parseInt(strArray[0]); i++) {
					for (int j = 0; j <  Integer.parseInt(strArray[1]); j++) {
						s.append("#");						
					}
					s.append(BR);
				}
				System.out.println(s);
				s.delete(0, s.length());
				line = br.readLine();			
			}				
			br.close();
		} catch (Exception e) {
			System.err.println(e);
		}
	}
}

Measured memory_bytes: 21640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  string S;
  cin >> S;
  string ret("ABC");
  if (S == "ABC") {
    ret = "ARC";
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3628
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB = sorted(AB, key=lambda x:x[1])

time_spent = 0
for a,b in AB:
    time_spent += a
    if time_spent > b:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 90072
H,W=map(int,input().split())
S=["."*(W+2)]+["."+input()+"." for i in range(H)]+["."*(W+2)]
for i in range(H):
    for j in range(W):
        c=S[i+1][j+1]
        if c==".":
            c=sum([S[k][j:j+3].count("#") for k in range(i,i+3)])
        print(c,sep="",end="")
    print("")

Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	int a,b;
	cin>>a>>b;
	vector<int> v(14);
	FOR(i,1,14){
		v[i]=(i-1);
	}
	v[1]=13;
	cout<<((v[a]>v[b])?"Alice":((v[b]>v[a])?"Bob":"Draw")) <<endl;
	return 0;
}












Measured memory_bytes: 256
M,D=map(int,input().split())
MX = 10**9+7
 
import math
if abs(M - D) >= 2:
  print(0)
elif abs(M - D) == 1:
  ANS=math.factorial(M) * math.factorial(D)
  if ANS >= MX:
    ANS %= MX
  print(ANS)
else:
  ANS=math.factorial(M)
  #if ANS >= MX:
  #  ANS %= MX
  print((ANS * ANS * 2) % MX)

Measured memory_bytes: 5180
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = sum(B)
for i, AA in enumerate(A[0:N-1]):
    if AA + 1 == A[i+1]:
        point = point + C[AA-1]
print(point)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int k, s;
  cin >> k >> s;
  long long int ans = 0;
  for (int i = 0; i <= min(k, s); i++) {
    for (int j = 0; j <= min(k, s); j++) {
      int t = s - i - j;
      if (0<= t && t <= k) {
        ans++;
      }
    }
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a <= b){
      System.out.println(a);
    }else{
      System.out.println(a-1);
    }
  }
}


Measured memory_bytes: 21844
e=input
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


Measured memory_bytes: 5612
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll ans = 0;
    ll sum = A[0], xsum = A[0];
    int l = 0, r = 1;

    for(int l=0; l<N; l++) {
         while(r < N && ((sum + A[r]) == (xsum^A[r]))) {
             sum += A[r];
             xsum ^= A[r];
             r++;
         }
         ans += r-l;
         sum -= A[l];
         xsum ^= A[l];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    double ans = (double) w*h/2;
    int num = (w = 2*x && h == 2*y)? 1:0;
    printf ("%.10f%d\n",ans);
    cout << " "  << num;
    rn 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k,r,s,p,ans=0;
  string t;
  cin>>n>>k;
  cin>>r>>s>>p;
  cin>>t;
  for(int i=0;i<k;i++){
    if(t[i]=='r'){
      ans+=p;
    }else if(t[i]=='s'){
      ans+=r;
    }else if(t[i]=='p'){
      ans+=s;
    }
  }
  for(int i=k;i<n;i++){
    if(t[i]==t[i-k]){
      t[i]='x';
      continue;
    }
    if(t[i]=='r'){
      ans+=p;
    }else if(t[i]=='s'){
      ans+=r;
    }else if(t[i]=='p'){
      ans+=s;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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


int main()
{
  int n;
  cin >> n;
  int ans = 0;
  for (int i=1; i<=n; i++)
    if (to_string(i).size() % 2)
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);


using namespace std;

const int N = 26;


int main()
{
    int n; cin >> n;
    set<string> s;
    map<string, int> nm;
    int maxas = 0;
    FOR(i, n, 0)
    {
        string nw; cin >> nw;
        nm[nw]++;
        maxas = max(maxas, nm[nw]);
        s.insert(nw);
    }
    set<string> ans;
    for(auto e : s)
    {
       if(nm[e] == maxas)ans.insert(e);
    }
    for(auto e : ans)cout << e<< endl;
    return 0;
}


Measured memory_bytes: 43904
#include<stdio.h>
#include<iostream>
using namespace std;
const int M=1e6+9;
long long a[M];
int main()
{
	long long n;
	scanf("%lld",&n);
	long long num=1;
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		num*=2;
		if(num==n)
		{
			ans=num*2-1;
			break;
		}
		else if(num>n)
		{
			ans=num-1;
			break;
		}
	}
	printf("%lld\n",ans);
	
} 

Measured memory_bytes: 256
package main

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

func main() {
	R := nextInt()

	fmt.Printf("%.2f\n", float64(R)*2*3.14)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1788