akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (!(a==b || (b==c || c==a))){
      System.out.println(3);
    }else if (a==b && b==c){
      System.out.println(1);
    }else{
      System.out.println(2);
    }
  }
}


Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    ll m = 1000, s = 0;
    bool buy = true;
    for (int i = 0; i < n-1; i++) {
        if (buy) {
            if (a[i] >= a[i+1])
                continue;
            ll num = m / a[i];
            s += num;
            m -= num * a[i];
            buy = false;
            //cout << i << ":" << a[i] << " buy:" << num << " -> " << m << ", " << s << endl;
        }
        else {
            if (a[i] <= a[i+1])
                continue;
            m += s * a[i];
            s = 0;
            buy = true;
            //cout << i << ":" << a[i] << " sell:" << m << ", " << s << endl;
        }
    }
    
    m += s * a[n-1];
    cout << m << endl;
    
    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}

int main(){
    string s;
    cin >> s;

    int N = s.size();

    ll K = 1;
    string pre = s.substr(0, 1);

    int i = 1;
    while (i < N) {
        int j = 1;
        while (i + j < N && pre == s.substr(i, j)) j++;

        if (i == N - 1 && pre.size() == 1 && j == 1 && s[N - 2] == s[N - 1]) break;

        pre = s.substr(i, j);
        i += j;

        K++;
    }

    cout << K << endl;
 
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
 
int main(){
	ll q,c,x;
	cin >> q;
	set<ll> se;
	while(q--){
		cin >> c >> x;
		if(c){
			cout << se.count(x) << endl;
		}else{
			se.insert(x);
			cout << se.size() << endl;
		}
	}
}


Measured memory_bytes: 12456
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    l b=0,c=0,x;
    cin>>x;
    string a;
    cin>>a;
    for(int i=1;i<a.size();i++){
        for(int j=0;j<i;j++){
            l y=1;
            for(int k=0;k<j;k++){
                if(a[k]==a[j]) y=0;
            }
            if(y){
                for(int k=i;k<a.size();k++){
                    l z=1;
                    for(int q=i;q<k;q++){
                        if(a[k]==a[q]) z=0;
                    }
                    if(a[j]==a[k]&&z) b++;
                }
            }
        }
        if(c<b) c=b;
        b=0;
    }
    cout<<c<<endl;
}
    

Measured memory_bytes: 256
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
//文字列の長さが偶数か奇数かで場合分け
int main(void){
    char s[201],t[201];
    int i,j=0,d,p;
    int n;
    scanf("%s",s);
    int len;
    len=strlen(s);
    for(i=2;i<len;i+=2){
        //dは文字列の長さ(常に偶数)
        d=len-i;
        j=0;
        p=d/2;
        while(s[j]==s[p]){
            if(j==d/2)break;
            j++;
            p++;
        }
        if(j==d/2){printf("%d\n",d);
            return 0;
        }
    
    }
    printf("1\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>

int main() {
    std::string str;
    std::cin >> str;
    std::vector<long long> count(26, 0ll);
    long long ret = str.size() * (str.size() - 1) / 2 + 1;

    for (auto c : str) {
        count[c - 'a']++;
    }

    for (auto n : count) {
        if (n > 1) ret -= n * (n - 1) / 2;
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

typedef struct{
	char name[20];
	int p;
	long m;
}classes;

int main(void){
	classes cla[9];
	int a, b, i;
	
	for(i=0; i<9; i++){
		scanf(" %s %d %d", cla[i].name, &a, &b);
		cla[i].p = a+b;
		cla[i].m = 200*a + 300*b;
	}
		
	for(i=0; i<9; i++)
		printf("%s %d %ld\n", cla[i].name, cla[i].p, cla[i].m);
	
	return 0;
}

Measured memory_bytes: 596
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

ll factorial (ll K){
  ll ans = 1;
  for (ll i = 1; i <= K; i++){
    ans *= i; ans %= nmax;
  }
  return ans;
}

ll AN(ll A, ll N){
  if (N == 0) return 1;
  else{
    if (N % 2 == 0){
      return AN(A * A % nmax, N / 2) % nmax;
    }else{
      return AN(A * A % nmax, N / 2) % nmax * A % nmax;
    }
  }
}

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

  vector <ll> C(N);
  C[0] = factorial(N - 1); C[N - 1] = C[0];
  for (ll i = 1; i < N - 1; i++){
    C[i] = C[0] * AN(i + 1, nmax - 2);
    C[i] %= nmax;
    C[N - 1] += C[i]; C[N - 1] %= nmax;
  }

  ll ans = 0;
  for (int i = 0; i < N - 1; i++){
    ans += X[i] * C[i]; ans %= nmax;
  }
  ans = -1 * ans; ans %= nmax; ans = (ans + nmax) % nmax;

  ans += X[N - 1] * C[N - 1]; ans %= nmax;
  cout << ans << endl;

  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> p;
    p.resize(m);
    int ans = 0;
    
    for(int i=0; i<m; i++){
        cin >> p[i].second >> p[i].first;
    }
    sort(p.begin(), p.end());
    
    int c = 0;
    for(int i=0; i<m; i++){
        auto& t = p[i];
        if(c > t.second){
            continue;
        }else{
            c = t.first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  long long int x,yokin = 100;
  int year = 0;
  scanf("%lld",&x);
  
  do
  {
    year++;
    yokin = yokin + ( yokin * 0.01);
  } while ( yokin < x );
  printf("%d\n",year);
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s1=sc.next();
		String s2[]=s1.split("");
		int count=0;
		for(String s:s2) {
			if(s.equals("1")) count++;
		}
		System.out.print(count);
	}
}

Measured memory_bytes: 35684
#include <stdio.h>

int main(){
  int i,j,k;
  int flag = 0;
  int s[5];
  for(i=0;i<5;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d", &k);
  
  for(i=0;i<5;i++){
    for(j=0;j<5;j++){
  	  if((s[i]-s[j])>=((-1)*k)&&(s[i]-s[j])<=k){
      }else{
        flag += 1;
      }
    }
  }
  if(flag == 0){
    printf("Yay!");
  }else if(flag != 0){
    printf(":(");
  }
  
  return 0;
}
        
   

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

using namespace std;

const int N = 100005;
const int K = 20;

int stepmem[N*K*5], remmem[N*K*5];

int suc[N], x[N];

int gap;
int memcnt = 0;

int *step[N*4];
int *rem[N*4];

void build(int nd, int l, int r) {
//    cout << "build nd = " << nd << ", l = " << l << ", r = " << r << "\n";

    step[nd] = stepmem + memcnt;
    rem[nd] = remmem + memcnt;
    memcnt += (r-l+1);

    int md = r-l;

    step[nd][md] = 1;
    rem[nd][md] = r;

    for (int i = md-1; i >= 0; i--) {
        if (suc[i+l] > r) {
            step[nd][i] = 1;
            rem[nd][i] = i+l;
        }
        else {
            step[nd][i] = step[nd][suc[i+l]-l] + 1;
            rem[nd][i] = rem[nd][suc[i+l]-l];
        }
    }
/*
    for (int i = 0; i <= md; i++)
        cout << "i = " << i << " (" << i+l << ") : " << step[nd][i] << " " << rem[nd][i] << "\n";
*/
    if (l == r) return;

    md = (l+r) >> 1;
    nd <<= 1;
    build(nd, l, md);
    build(nd^1, md+1, r);
}

pair<int,int> query(int nd, int l, int r, int tr, int ph) {
//    cout << "query nd = " << nd << ", l = " << l << ", r = " << r << ", tr = " << tr << ", ph = " << ph << "\n";

    if (ph == r) {
        return {step[nd][tr-l], rem[nd][tr-l]};
    }

    int m = (l+r) >> 1;
    int cc = (nd << 1);
    if (ph <= m) return query(cc, l, m, tr, ph);
    if (tr > m) return query(cc^1, m+1, r, tr, ph);

    auto p = query(cc, l, m, tr, m);
    int u = suc[p.second];
    int tmp = p.first;

    if (u >= ph) return p;

    p = query(cc^1, m+1, r, u, ph);
    return {tmp + p.first, p.second};
}

int main() {
//    freopen("C.in", "r", stdin);
//    freopen("C.out", "w", stdout);

    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) scanf("%d", x+i);

    int q;
    scanf("%d%d", &gap, &q);

    for (int i = n, j = n; i >= 1; i--) {
        while (j >= i && x[i]+gap < x[j]) j--;
        suc[i] = j;
    }

    build(1, 1, n);

    while (q--) {
        int u, v;
        scanf("%d%d", &u, &v);
        if (u > v) swap(u, v);
        auto p = query(1, 1, n, u, v);
        int ans = p.first;
        if (p.second == v) ans--;
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 19584
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define pi acos(-1)
int main()
{
    int a,b,h,m;
    double s,t,r;
    scanf("%d%d%d%d",&a,&b,&h,&m);
    t=m*360/60;
    s=h*30+m*0.5;
    t=fabs(s-t);
    r=a*a+b*b-2*a*b*cos(t*pi/180);
    r=sqrt(r);
    printf("%.20lf\n",r);
    return 0;
}


Measured memory_bytes: 2632
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int H, W, N, sh, sw;
  cin >> H >> W >> N >> sh >> sw;
  string S, T;
  cin >> S >> T;
  
  int l, r, u, d;
  l = 1; r = W;
  u = 1; d = H;
  for (int i=N-1; i>=0; i--){
    switch (T[i]) {
      case 'L':
        r = min(r+1, W); break;
      case 'R':
        l = max(l-1, 1); break;
      case 'U':
        d = min(d+1, H); break;
      case 'D':
        u = max(u-1, 1); break;
    }
    switch (S[i]) {
      case 'L':
        l++; break;
      case 'R':
        r--; break;
      case 'U':
        u++; break;
      case 'D':
        d--; break;
    }
    if (r<l || d<u) break;
  }
  
  bool ans = (l <= sw && sw <= r && u <= sh && sh <= d);
  cout << (ans ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 776
/**
 * C - Otoshidama
 * https://atcoder.jp/contests/abc085/tasks/abc085_c
 **/
#include<iostream>

using namespace std;

int main() {
    int N, Y;
    cin >> N >> Y;
    bool flag = false;
    int ax = -1, ay = -1, az = -1;
    int x = Y/10000;
    for(int i=x; i>=0; i--) {
        int y = (Y-10000*i)/5000;
        for(int j=y; j>=0; j--) {
            int z = (Y-10000*i-5000*j)/1000;
            if((Y-10000*i-5000*j)%1000==0) {
                if(i+j+z==N) {
                    flag = true;
                    ax = i;
                    ay = j;
                    az = z;
                }
            }
        }
    }
    if(flag==false) {
        ax = -1;
        ay = -1;
        az = -1;
    }
    cout << ax << " " << ay << " " << az << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int dig = 0, bi = 0, mill = 0, mil = 0, cent = 0, dez = 0, uni = 0, res = 0, num = 0;
    scanf("%d", &dig);
    num = dig;

    while (dig != 0)
    {
        res  += dig % 10;
        dig  = dig / 10;
    }

    if (num % res == 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
int cnt=0;

void dfs(int depth , int k , int sum ){
	if(depth==n){
		if(k==0){
			cnt++;
			return;
		}
	}
	if(k<0) return;
	for(int i=sum; i<10 ; i++){
		dfs(depth+1 , k-i , i+1);
	}
}

int main(){
	int s;
	while(cin>> n >> s , (n || s)){
		dfs(0,s,0);
		cout << cnt << endl;
		cnt=0;
	}
	return 0; 
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
////////////////////////////////
 
#define int long long

const int mod = 1e9 + 7;
const int N = 10001;
int n;
int x;
string s;
int dp[N][10][2][100];
// f is zero means we can do anything .
// f is not zero means we are limited .
int calc(int pos ,int val , int f , int sum){

	if(pos==n){

		return (sum==0);
	}

	int &ans = dp[pos][val][f][sum];

	if(ans!=-1)
		return ans;

	int lim = 9;

	if(f==1)
		lim = s[pos]-'0';
	ans = 0;
	for(int i = 0 ; i <= lim ; ++i){

		if(f==0)
			ans += calc(pos+1 , i , 0 , (sum+i)%x);
		else if(i==lim && f==1)
			ans += calc(pos + 1 , i , 1 , (sum + i)%x);
		else ans += calc(pos+1 , i , 0 , (sum + i)%x);

		if(ans >= mod)
			ans-=mod;
	}

	return ans;

}

void solve(){

	memset(dp , -1 , sizeof dp);

	cin>>s;

	n = s.size();

	cin>>x;


	int ans = calc(0 , 0 , 1 , 0);

	--ans;

	if(ans < 0)
		ans += mod;

	cout<<ans<<endl;
}
 
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 157440
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

int check(int m, int d) {
  int d1, d10;
  d1 = d % 10;
  d10 = d / 10;
  if ((d1 >= 2) && (d10 >= 2) && (d10 * d1 == m)) {
    return 1;
  }
  return 0;
}
void input() {
  ;
  cin >> N >> M;
  int ans = 0;
  rep(mm, 1, N) {
    rep(dd, 1, M) {
      if (check(mm, dd)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  ;
}
void solve() {
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#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, m;
  string s;
  cin >> n >> m >> s;
  vector<int> v;
  int crt = n;
  while (true)
  {
    if (crt <= m)
    {
      v.push_back(crt);
      break;
    }
    for (int i = m; i > 0; i--)
    {
      if (s[crt-i] == '0')
      {
        v.push_back(i);
        crt -= i;
        break;
      }
      if (i == 1)
      {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = v.size() - 1; i >= 0; i--)
    printf("%d%c", v[i], i==0?'\n':' ');
  return 0;
}

Measured memory_bytes: 1144
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;

    regex re("^(dream|dreamer|erase|eraser)+$");

    string ans = regex_search(S, re) ? "YES" : "NO";
    
    cout << ans << endl;  

    return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  int m;
  if (A + B <= N) {
    m = 0;
  } else {
    m = A + B - N;
  }
  cout << min(A, B) << " " << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    while(cin>>str){
        int A[2019]={0},rslt=0,pre=0,t=1;
        A[0]++;
        int n=str.size();
        for(int i=0;i<n;i++){
            rslt+=A[(pre+=(str[n-1-i]-'0')*t)%=2019]++;
            (t*=10)%=2019;
        }
        cout<<rslt<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  int res = 1;
  for(ll i = 2; i * i <= g; ++i) {
    if(g % i == 0) {
      res++;
      while(g % i == 0) g /= i;
    }
  }
  if(g > 1) res++;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define inf 2147483647
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;

int cnt[2];

int main () {
    std::string str;
    std::cin >> str;
    int n = str.size();
    for (int i = 0; i < n; ++i) {
        ++cnt[str[i] - '0'];
    }
    write(std::min(cnt[0], cnt[1]) << 1), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 512
/**
 *    Author:  Oak_limy
 *    Created: 2020-08-29 21:02:52
**/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
       if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
    char c = getchar(); int w = 1; int x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
inline ll readll() {
    char c = getchar(); ll w = 1; ll x = 0;
    while (!isdigit(c))
        (c == '-') && (w = -w), c = getchar();
    while (isdigit(c))
        x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
    x *= w;
    return x;
}
void fl(string name){
    freopen((name+".in").c_str(),"r",stdin);
    freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
          dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define MAXN 200010
const ll p=1e9+7;
ll sum[MAXN],res[MAXN],a[MAXN];
int main(){
    ll n,tot=0;
    cin>>n;
    rp(i,1,n){
        cin>>a[i];
        a[i]%=p;
    }
    for(int i=1;i<=n;i++)sum[i]=(sum[i-1]+a[i])%p;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans=(ans+(sum[i-1]*a[i])%p)%p;
    }
    cout<<ans%p<<endl;
}
/* stuff to remember
    * int overflow, array bounds
    * special cases (n=1? n=0?)
    * do something instead of nothing and stay organized
    * USE STATIC ARRAYS
    * DEFINING ARRAYS BEFORE main()
    * DO NOT DEFINE ARRAYS IN main()
    * USE INT INSTEAD OF LL,NOTICE THE MLE
*/


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
int a,b;
cin>>a>>b;
if(a%2==1&&b%2==1){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

int main(void){
  int n;
  std::cin >> n;
  std::cout << (n+1)/2 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 2e5 + 10, mod = 998244353;
typedef long long ll;
ll n, ans;
ll deg[N];
set<int> s[N];

ll quick_pow(ll a, ll b) {
    ll ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
    } return ret;
}

int main() {
    cin >> n;
    rep(i, 1, n - 1) {
        int x, y; scanf("%d%d", &x, &y);
        deg[x]++, deg[y]++;
        s[x].insert(y), s[y].insert(x);
    }
    ll inv2 = quick_pow(2, mod - 2), inv4 = quick_pow(4, mod - 2);
    ans = n * (n - 1) % mod * inv4 % mod;
    ans = (ans - 2 * (n - 1) * (n - 2) % mod * inv2 % mod * inv4 % mod + mod) % mod;
    rep(i, 1, n - 1) {
        int x, y; scanf("%d%d", &x, &y);
        ll t = s[x].size() + s[y].size() - (s[x].find(y) != s[x].end());
        ans = (ans + (n - 1 - t) * inv4 % mod * inv4 % mod) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 32904
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	vector<int> s;
	for(int i = 0; i * i <= (1 << 15); ++i){
		s.push_back(i * i);
	}
	const int m = s.size();
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int answer = 0;
		for(int a = 0; a < m; ++a){
			if(s[a] > n){ break; }
			for(int b = a; b < m; ++b){
				if(s[a] + s[b] > n){ break; }
				for(int c = b; c < m; ++c){
					int sum = s[a] + s[b] + s[c];
					if(sum > n){ break; }
					if(binary_search(s.begin() + c, s.end(), n - sum)){
						++answer;
					}
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

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

int pickLast(int times[5]) {
  int min = 99;
  int idx = 0;
  for (int i = 0; i < 5; i++) {
    int surplus = times[i] % 10;
    if (min > surplus && surplus != 0) {
      min = surplus;
      idx = i;
    }
  }
  return idx;
}

int main() {
  int times[5];
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    cin >> times[i];
  }
  int idx = pickLast(times);
  for (int i = 0; i < 5; i++) {
    if (i == idx) {
      continue;
    }
    sum += times[i];
    int surplus = sum % 10;
    if (surplus != 0) {
      sum += 10 - surplus;
    }
  }
  sum += times[idx];
  cout << sum;
  return 0;
}

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

#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
typedef long double ld;
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
const int N=1005, mxN=(1<<22);
int mod=1e9+7;
int n,m,k;
string s[12];
int ans=1e9;
int solve(vector<int> v)
{
    int ans=v.size()-1;
    int co[12]={};

    for(int j=0;j<m;j++)
    {
        int c=0;
        int ind=0;
        bool cut=0;
        for(int i=0;i<n;i++)
        {

            if(i==v[ind])
            {
                if(c>k)
                    return 1e9;

                if(c+co[ind]>k)
                {
                    cut=1;
                }
                else
                {
                    co[ind]+=c;

                }
                c=0;
                ind++;
            }
            if(s[i][j]=='1')
                c++;
}

                if(c>k)
                    return 1e9;

                if(c+co[ind]>k)
                {
                    cut=1;
                }
                else
                {
                    co[ind]+=c;

                }
     /* cout<<"counters ";
      for(int z=0;z<v.size()-1;z++)
        cout<<co[z]<<" ";
      cout<<"cut= "<<cut<<endl;
       */ if(cut)
        {
            for(int i=0;i<v.size();i++)
                co[i]=0;
            ans++;
            j--;
        }


    }

    return ans;
}
void bruteforce(vector<int>v, int i)
{
    if(i==n)
    {
    v.push_back(n);
    ans=min(ans,solve(v));
  /*  for(int j=0;j<v.size();j++)
    {
        cout<<v[j]<<" ";

    }
    cout<<ans<<endl;
*/
    return ;

    }
    bruteforce(v,i+1);
   v.push_back(i);
    bruteforce(v,i+1);
    v.pop_back();

}


int main()

{    FIO
cin>>n>>m>>k;
for(int i=0;i<n;i++)
    cin>>s[i];
    vector<int>v;
bruteforce(v,1);
cout<<ans;


    return 0;

}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll 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 fact[200003];
ll ifact[200003];
ll Combination(ll a,ll b) {
  ll s = (fact[a] * ifact[b]) % Mod;
  return (s * ifact[a-b]) % Mod;
}

int main() {
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i <= 200003; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= Mod;
    ifact[i] = modinv(fact[i],Mod);
  }
  ll N,M,K;
  cin >> N >> M >> K;
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    ll a = i * (N - i);
    a %= Mod;
    a *= M * M;
    a %= Mod;
    res += a;
    res %= Mod;
  }
  for (ll i = 0; i < M; i++) {
    ll a = i * (M - i);
    a %= Mod;
    a *= N * N;
    a %= Mod;
    res += a;
    res %= Mod;
  }
  ll C = Combination(N*M - 2,K - 2);
  ll ans = res * C;
  ans %= Mod;
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  double n, k;
  cin >> n >> k;
  vector <double> v(n, 0);
  rep(i, n) {
    double tmp = i+1;
    while (tmp < k) {
      v.at(i)++;
      tmp *= 2;
    }
  }
  double ans = 0;
  rep(i, n) ans += pow(0.5, v.at(i));
  cout << fixed << setprecision(12);
  cout << ans/n << endl;
}

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

int GCD(int a,int b);
int main(void){
   
   int N;
   
   scanf("%d",&N);
   
   int *A = malloc(sizeof(int)*N);
   
   int i;
   
   for(i = 0;i < N;i++){
      scanf("%d",&A[i]);
   }
   
   int gcd = A[0];
   
   for(i = 0;i < N;i++){
      gcd = GCD(gcd,A[i]);
   }
   
   printf("%d\n",gcd);
   
   return 0;
   
}

int GCD(int a,int b){
   
   int temp,r;
   
   if(a < b){
      temp = a;
      a = b;
      b = temp;
   }

   r = a%b;

   while(r != 0){
      a = b;
      b = r;
      r = a%b;
   }

   return b;
   
   
}



Measured memory_bytes: 512
def draw_rect(H,W):
    for i in range(H):
        for j in range(W):
            print("#",end="")
        print("")


def read_data():
    ls=[]
    while True:
        s,t=tuple(input().split())
        
        H=int(s)
        W=int(t)
        
        if H==0 and W==0:
            break
        
        ls.append((H,W))
        
    return ls


def draw_all_rect(ls):
    for W,H in ls:
        draw_rect(W,H)
        print("")


ls=read_data()
draw_all_rect(ls)



Measured memory_bytes: 7012
num = int(input())
coms = []

ans_num = 0

for com in range(num):
    b = []
    n = int(input())
    for _ in range(n):
        xi,yi = [int(j) for j in input().split(" ")]
        b.append([int(xi) - 1, int(yi)])
    coms.append(b)

for i in range(2 ** num):
    selects = []
    ans_array = [0 for _ in range(num)]
    indexes = []
    flag = True

    #組み合わせの作成
    for j in range(num):
        if((i >> j) & 1):
            selects.append(coms[j])
            indexes.append(j)
            ans_array[j] = 1
    
    for index in indexes:
        for com in coms[index]:
            if ans_array[com[0]] != com[1]:
                flag = False
                break

    if flag and (len(indexes) >= ans_num):
        ans_num = len(indexes)

print(ans_num)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()

print(len(s)-s[::-1].index("Z")-s.index("A"))


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

ll p = 1e9+7;

// a^n mod p
ll f(ll a, ll n) {
	if (n==0) return 1;
	else if (n==1) return a;
	else {
		ll x = f(a, n/2);
		ll ans = ((x * x) % p) * f(a,n-2*(n/2)) % p;
		return ans;
	}
}

int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> cnt(k+1,0);
	for (ll i=k;i>=1;i--) {
		cnt[i] = f(k/i,n);
		for (ll j=2;i*j<=k;j++) cnt[i] = (cnt[i] + p - cnt[j*i]) % p;
		//printf("%lld %lld\n", i, cnt[i]);
	}
	ll ans = 0;
	rep(i,k+1) ans = (ans + i * cnt[i]) % p;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

ll gcd(ll x, ll y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    return gcd(y,x%y);
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll m = c * d / gcd(c,d);
  ll ans = b - a + 1 - (b/c - a/c +(a%c==0)+ b/d - a/d + (a%d==0) -(b/m - a/m + (a%m==0)));
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		unsigned x;
		cin >> x;

		bitset<32> b( x );
		cout << b << '\n'
			<< ~b << '\n'
			<< (b << 1) << '\n'
			<< (b >> 1) << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    ll h,w,k;cin>>h>>w>>k;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll ans=0;
    rep(i,0,(1<<h)-1){
        rep(j,0,(1<<w)-1){
            ll sum=0;
            rep(I,0,h-1){
                rep(J,0,w-1){
                    if(((i>>I)&1)==1 && ((j>>J)&1)==1 && s[I][J]=='#'){
                        sum++;
                    }
                }
            }
            if(sum==k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3604
<?php
	$input = explode(" ", trim(fgets(STDIN)));
	$a = $input[0];
	$b = $input[1];
	$h = $input[2];
	$m = $input[3];

	$long = 6 * $m;
	$short = 30 * $h + $m / 2;
	$alpha = 0;
	if($long > $short) {
      $alpha = $long - $short;
    } else {
      $alpha = $short - $long;
    }
	if($alpha > 180){
      $alpha = 360 - $alpha;
    }
	
	$powc = pow($a, 2) + pow($b, 2) - 2 * $a * $b * cos(deg2rad($alpha));
	$c = sqrt($powc);
	echo $c;
?>

Measured memory_bytes: 16596
N, W = tuple(map(int,(input().split())))
items = []

memo = [[-2]*(W+1) for i in range(N+1)]

weight = 1
value = 0

for i in range(N):
   item = tuple(map(int,(input().split())))
   items.append(item)

def comb(i, c):
    if memo[i][c] != -2:
        return memo[i][c]
    if i == N:
        return 0
    
    v = 0
    u = comb(i+1, c)
    if c-items[i][weight] >= 0:
        v = comb(i+1, c-items[i][weight]) + items[i][value]
    best = max(u,v)
    memo[i][c] = best
    return best

print(comb(0,W))


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

int main()
{
	char Str[21];
	int StrLen;

	cin >> Str;

	StrLen = strlen( Str );

	while( 1 ){

		cout << Str[StrLen-1];

		StrLen--;

		if( StrLen == 0 ) break;
	}

	cout << endl;

	return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    int ans = 0;
    
    rep(i, 1000){
        vector<char> c(3, '0');
        int i_ = i;
        rep(j, 3){
            int x = i_%10;
            i_ -= x;
            i_ /= 10;
            c[2-j] += x;
        }
        
        int cnt = 0;
        rep(j, n){
            if(c[cnt]==s[j])cnt++;
        }
        if(cnt==3)ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int n, p;
	while (cin >> n >> p) {
		if (n == 0 && p == 0)
			break;

		int ans = -1, bp = p;
		vector<int> r(n, 0);
		for (int i = 0; ; ++i) {

			if (p == 0) {
				p = r[i%n];
				r[i%n] = 0;
			} else {
				--p;
				++r[i%n];
				if (p == 0) {
					for (unsigned int j = 0; j < r.size(); ++j) {
						if (r[j] == bp) {
							ans = j;
							break;
						}
					}

					if (ans != -1)
						break;
				}
			}

		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 904
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static System.Console;

namespace AtCoder
{
    class AddSubMul
    {
        static void Main()
        {
            var ab = ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);
            WriteLine(Math.Max(a + b, Math.Max(a - b, a * b)));
        }
    }
}


Measured memory_bytes: 11092
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//#include<windows.h>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
//#define view Sleep(2000)


signed main() {

	int a, b;
	cin >> a >> b;
	a = a*b;
	if (a % 2 == 0) {
		cout << "Even" << endl;
	}
	else cout << "Odd" << endl;
	system("pause");
}

Measured memory_bytes: 504
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
INF = 10<<10

V = H*W
maze = [[INF]*V for _ in range(V)]

#隣接行列（対角成分）
for i in range(V):
    maze[i][i] = 0

#隣接行列（経路があれば1）
for py in range(H):
    for px in range(W):
        if s[py][px] == '#': continue
        target = [(px+1, py), (px-1, py), (px, py+1), (px, py-1)]
        for x, y in target:
            if not (0<=x<W and 0<=y<H): continue
            if s[y][x] == '#': continue
            maze[W*py+px][W*y+x] = 1

#ワーシャル・フロイド
for k in range(V):
    for i in range(V):
        for j in range(V):
            maze[i][j] = min(maze[i][j], maze[i][k]+maze[k][j])

print(max([j for i in maze for j in i if j!=INF]))


Measured memory_bytes: 51164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{

  ll a,b;
  cin>>a>>b;
  if(a==13&&b==1)a=0;
  if(a==1&&b==13)b=0;
  if(a>b){
    cout<<"Alice"<<endl;
  }else if(a<b){
    cout<<"Bob"<<endl;
  }else{
    cout<<"Draw"<<endl;
  }


  return 0;
}


Measured memory_bytes: 3592
import java.util.*;

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

		while (sc.hasNext()) {
			String data = sc.nextLine();

			// List<Integer> list = new ArrayList<>();
	 		// for (String s : data.split("\\s+")) {
			// 	list.add(Integer.parseInt(s));
			// }

			int sz = data.length();
			int res = 0;

			for (int i=0; i<sz/2; i++) {
				if (data.charAt(i) != data.charAt(sz-1-i)) {
					res ++;
				}
			}

			System.out.println(res);
		}
	}
}


Measured memory_bytes: 24020