akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	int as,kl,o;
	String n,m;
	Scanner sc = new Scanner(System.in);
	public void solve() {	
	n=sc.next();
	m=sc.next();
	//String[] date=new String[n.length()];
	//String[] dat=new String[n.length()];
	//for(o=0;o<n.length();o++) {
	String[]	date=n.split("");
	String[]	dat=m.split("");
	//}
	for(o=0;o<n.length();o++) {
		//System.out.println(date[o]);
	//	System.out.println(dat[o]);
		if(date[o].equals(dat[o])) {
			as=as+1;
		}
	}
	as=n.length()-as;
	System.out.println(as);
	}
	public static void main(String[] args) {
		new Main().solve();
	
	}
}


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

class UnionFind
{
    std::vector<std::size_t> root;
    const std::size_t maximum_size;

public:
    UnionFind(const std::size_t N) : maximum_size(N + 5)
    {
        this->root = std::vector<std::size_t>(N + 1, this->maximum_size);
    }

    std::size_t find_root(const std::size_t A)
    {
        if (this->root[A] >= this->maximum_size)
        {
            return A;
        }
        this->root[A] = this->find_root(this->root[A]);
        return this->root[A];
    }

    std::size_t size(const std::size_t A)
    {
        return this->root[this->find_root(A)] - this->maximum_size + 1;
    }

    bool unite(const std::size_t A, const std::size_t B)
    {
        std::size_t rootA = find_root(A);
        std::size_t rootB = find_root(B);
        if (rootA == rootB)
        {
            return false;
        }

        if (this->size(rootA) < this->size(rootB))
        {
            std::swap(rootA, rootB);
        }

        this->root[rootA] += this->size(rootB);
        this->root[rootB] = rootA;

        return true;
    }

    bool has_same_root(const std::size_t A, const std::size_t B)
    {
        return this->find_root(A) == this->find_root(B);
    }
};

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

    UnionFind uf(N);
    size_t A, B;
    for (size_t i = 0; i < M; i++)
    {
        cin >> A >> B;
        uf.unite(A, B);
    }
    set<size_t> ans;
    for (size_t i = 1; i <= N; i++)
    {
        ans.insert(uf.find_root(i));
    }
    cout << ans.size() - 1 << endl;
}


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

long int Min(long int a, long int b);
long int Max(long int a, long int b);

long int Min(long int a, long int b){
  return a > b ? b : a;     
}

long int Max(long int a, long int b){
  return a < b ? b : a;
}

int main() {
  long int w,h, wh, div3;
  long int max0, min0, max1, min1, minmax0=0, minmax1=0;
  long int best0=0x7fffffffffffffff, best1=0x7fffffffffffffff;
  long int p1,p2v,p3v,p2h,p3h;
  
  // 画枠入力
  cin >> h >> w;
  
  wh = w*h;
  
  //最初にhorizonatal方向に切る
  for(int i=1; i<h; i++){
    p1 =  w*i;
    p2h = w*(((h-i)+1)/2);
    p3h = w*(((h-i))/2);
    
    p2v = (w/2)*(h-i);
    p3v = ((w+1)/2)*(h-i);
    
    min0 = Min(Min(p2h, p3h), p1);
    max0 = Max(Max(p2h, p3h), p1);
    
    minmax0 = max0-min0;
    
    min0 = Min(Min(p2v, p3v), p1);
    max0 = Max(Max(p2v, p3v), p1);
    
    minmax0 = Min(max0 - min0, minmax0);
    
    //printf("%d, %d, %d, %d, %d, %d\n",p1 , p2h, p3h, p2v, p3v, minmax0);
    if(minmax0 <= best0) best0 = minmax0; 
  }

  //vertical方向
  for(int i=2; i<w; i++){
    p1 =  h*i;
    p2h = (w-i)*((h+1)/2);
    p3h = (w-i)*(h/2);
    
    p2v = ((w-i)/2)*h;
    p3v = ((w-i+1)/2)*h;
    
    min0 = Min(Min(p2h, p3h), p1);
    max0 = Max(Max(p2h, p3h), p1);
    
    minmax0 = max0-min0;
    
    min0 = Min(Min(p2v, p3v), p1);
    max0 = Max(Max(p2v, p3v), p1);
    
    minmax1 = Min(max0 - min0, minmax0);
    
    //printf("ver:%d, %d, %d, %d, %d, %d\n",p1 , p2h, p3h, p2v, p3v, minmax1);
    if(minmax1 <= best1) best1 = minmax1; 
  }
  
   cout << min(best0,best1) << endl;
}

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

#define int long long

using namespace std;

#ifdef LOCAL 
#include "/media/brayand/BrayanD/debugger.h"
#else
template<typename... Args>
void db(Args... args){}
#endif

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    string cad;

    while(N)
    {
    	N--;
    	cad += 'a'+(N%26);
    	N /= 26;
    }

    reverse(cad.begin(),cad.end());

    cout << cad << '\n';

    return 0;
}

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

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

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

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



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

    vector<long double> bw(21);
    bw[0]=1;
    for(int i=1;i<21;i++){
        bw[i] = bw[i-1] * 2;
    }

    double ans =0;

    FOR(i,1,N+1){ //サイコロのどの面が出たのか
        FOR(j,0,21){
            if(K<=i*bw[j]){
                ans += (long double)1.0/ ((long double)bw[j]);
                break;
            }
        }
    }

    cout << fixed << setprecision(10) << (ans)/N << endl;

}

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

from functools import reduce

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

ct = 0
num = gcd_list(li)
while num != 1:
    num /= 2
    ct += 1
print(ct)

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

void swap(int &x,int &y){
	int temp = x;
	x = y;
	y = temp;
}

int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x<0 || y<0)
		cout<<"No"<<endl;
	else if(W-(x+r) >= 0 && H-(y+r) >= 0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1] && a[0] != a[2] || a[0] != a[1] && a[1] == a[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

bool predication(const pair<int,int> &a, const pair<int,int> &b){
    return a.first < b.first;
}

int dpl[3003][3002] = {};
int dpr[3003][3002] = {};

int main(){
    std::ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    int a[n] = {};
    int b[n] = {};
    vector<pair<int,int>> vpii;
    for(int i=0;i<n;++i)
    {
        cin >> a[i] >> b[i];
        vpii.push_back(MP(a[i], b[i]));
    }

    for(int i=1;i<=n;++i)
    {
        for(int j=0;j<t;++j)
        {
            dpl[i][j] = max(dpl[i][j], dpl[i-1][j]);
            if(j + vpii[i-1].first <= t) {
                dpl[i][j + vpii[i-1].first] = max(dpl[i][j + vpii[i-1].first], dpl[i-1][j] + vpii[i-1].second);
            }
        }
    }

    for(int i=n;i>0;--i) {
        for(int j=0;j<t;++j)
        {
            dpr[i][j] = max(dpr[i][j], dpr[i+1][j]);
            if(j + vpii[i-1].first <= t) {
                dpr[i][j + vpii[i-1].first] = max(dpr[i][j + vpii[i-1].first], dpr[i+1][j] + vpii[i-1].second);
            }
        }
    }
    int res = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<t;++j)
        {
            res = max(res, dpl[i][j] + dpr[i+2][t - j - 1] + vpii[i].second);
        }
    }
    cout << res << endl;
}

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

int main()
{
  char number[10];
  cin >> number;
  int size = strlen(number);
  int i;
  int num[size];
  for(i = 0;i < size;++i){
    num[i] = number[i] - '0';
  }
  int temp = 100*num[0]+10*num[1]+num[2];
  int min = temp - 753;
  if(min < 0){
    min = (-1)*min;
  }
  int ans = min;
  for(i = 3; i < size;i++){
    temp = 100*num[i-2]+10*num[i-1]+num[i];
    min = temp - 753;
    if(min < 0){
      min = (-1)*min;
    }
    if(min < ans){
      ans = min;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N,1e18);
    dp[0] = 0;
    rep(i,N) {
        rep(j,K) {
            if (i < j+1) continue;
            chmin(dp[i],dp[i-j-1] + abs(h[i] - h[i-j-1])); 
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;

int main(){
    ll n,x,M;
    cin>>n>>x>>M;
    vector<int> f(100100,0);
    vector<int> sumation(100100,0);
    ll roop=1;
    ll sum=0;
    vector<ll> memo(0);
    int i=0;
    ll now=x;
    ll syokiti=0;
    ll s=0;
    for(;i<n;i++){
        if(f[now]>0){
            s=f[now];
            roop-=f[now];
            sum-=sumation[now];
            syokiti=sumation[now];
            break;
        }
        f[now]=roop;
        sumation[now]=sum;
        sum+=now;
        syokiti+=now;
        ///
        now=now*now%M;
        roop++;
    }
    if(i==n){
        cout<<sum<<endl;
        return 0;
    }
    //////
    //cout<<"syoki="<<syokiti<<" ,sum="<<sum<<" ,roop="<<roop<<" ,s="<<s<<endl;
    ll ans=syokiti;
    n-=s;
    ans+=(n/roop)*sum;
    for(int i=0;i<=n%roop;i++){
        ans+=now;
        now=now*now%M;
    }
    cout<<ans<<endl;

    
}

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

template <long long MOD>
struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv()); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }
  // M inv() const {
  //   int x, y;
  //   extgcd(this->v, MOD, x, y);
  //   return *this + M(x);
  // }

  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::fact = vector<ModInt<MOD>>();
template <long long MOD>
vector<ModInt<MOD>> ModInt<MOD>::finv = vector<ModInt<MOD>>();
using mint = ModInt<(long long)(1e9 + 7)>;

int main() {
  int n, k;
  cin >> n >> k;
  mint::build(n);
  for (int i = 1; i <= k; i++) {
    mint ans = mint::comb(n - k + 1, i) * mint::comb(k - 1, i - 1);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
const int maxn=44;
int k=38,beg[maxn],at[maxn],tmp[maxn];
int main(){
	printf("%d %d\n",k*(k-1)+1,k);
	int cnt=2;
	FOR(i,1,k){
		printf("1 ");
		at[i]=beg[i]=cnt;
		FOR(j,1,k-1) printf("%d ",cnt++);
		puts("");
	}
	beg[k+1]=k*(k-1)+2;
	FOR(i,2,k){
		FOR(j,2,k) tmp[j]=at[j];
		FOR(j,1,k-1){
			printf("%d ",i);
			FOR(_,2,k) printf("%d ",tmp[_]);
			puts("");
			FOR(_,2,k){
				tmp[_]++;
				while(tmp[_]>=beg[_+1]) tmp[_]-=beg[_+1]-beg[_];
			}
		}
		FOR(j,2,k){
			at[j]+=j-2;
			while(at[j]>=beg[j+1]) at[j]-=beg[j+1]-beg[j];
		}
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


int main()
{
    int N, K;

    cin >> N >> K;

    int p;

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

    sort(arr.begin(), arr.end());

    long long price = 0;
    for (int i = 0; i < K; i++) {
        price = price + arr[i];
    }

    cout << price << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 300005
using namespace std;

int main()
{
    int n;
    cin>>n;
    int cnt = 0;
    for(int i=0; i<n; i++)
    {
        ll a; cin>>a;
        while(a%2 == 0)
        {
            a/=2;
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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


int main()
{
    int n,a,cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&a);
        if(i%2==1&&a%2==1) cnt++;
    }
    cout<<cnt;
}

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

const int nMAXARY = 1000033;

long long fnStrToLL(string sKey)
{
  int nElm;
  int nBase = 1;
  long long nKey = 0;
  for (int i = sKey.size() - 1; i >= 0; i--)
  {
    switch (sKey[i])
    {
      case  'A': nElm = 1;
                 break;
      case  'C': nElm = 2;
                 break;
      case  'G': nElm = 3;
                 break;
      case  'T': nElm = 4;
                 break;
      default:   nElm = 0;
    }
    nKey += nBase * nElm;
    nBase *= 5;
  }
  return nKey;
}

int fnHash1(long long nKey) { return (nKey % nMAXARY); }
int fnHash2(long long nKey) { return (1 + (nKey % (nMAXARY - 1))); }

void fnDic(string stasDic[])
{
  int nCmdCnt;
  cin >> nCmdCnt;

  for (int i = 0; i < nCmdCnt; i++)
  {
    string sCmd;
    string sKey;
    cin >> sCmd >> sKey;

    long long nKey = fnStrToLL(sKey);
    int nCnt = 0;
    for (nCnt = 0; ;nCnt++)
    {
      int ix = (fnHash1(nKey) + nCnt * fnHash2(nKey)) % nMAXARY;
      if (stasDic[ix] == sKey)
      {
        if (sCmd[0] == 'i')
          break;
        else if (sCmd[0] == 'f')
        {
          cout << "yes" << endl;
          break;
        }
      }
      else if (stasDic[ix].size() == 0)
      {
        if (sCmd[0] == 'i')
        {
          stasDic[ix] = sKey;
          break;
        }
        else if (sCmd[0] == 'f')
        {
          cout << "no" << endl;
          break;
        }
      }
    }
  }
}

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

  static string stasDic[nMAXARY];
  fnDic(stasDic);
  
  return 0;
}

Measured memory_bytes: 23940
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Cake[] cakes = new Cake[n];
		for (int i = 0; i < n; i++) {
		    cakes[i] = new Cake(new long[]{sc.nextLong(), sc.nextLong(), sc.nextLong()});
		}
		Cake.sw = new int[]{1, 1, 1};
		Arrays.sort(cakes);
		long max = getMax(cakes, m);
		Cake.sw = new int[]{-1, 1, 1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		Cake.sw = new int[]{1, -1, 1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		Cake.sw = new int[]{1, 1, -1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		System.out.println(max);
    }
    
    static long getMax(Cake[] cakes, int count) {
        long fore = 0;
        long reer = 0;
        for (int i = 0; i < count; i++) {
            fore += cakes[i].getValue();
            reer += cakes[cakes.length - i - 1].getValue();
        }
        return Math.max(Math.abs(fore), Math.abs(reer));
    }
    
    static class Cake implements Comparable<Cake> {
        static int[] sw;
        long[] values;
        
        public Cake(long[] values) {
            this.values = values;
        }
        
        public long getValue() {
            long ans = 0;
            for (int i = 0; i < 3; i++) {
                ans += sw[i] * values[i];
            }
            return ans;
        }
        
        public int compareTo(Cake another) {
            long x = getValue();
            long y = another.getValue();
            if (x == y) {
                return 0;
            } else if (x < y) {
                return -1;
            } else {
                return 1;
            }
        }
    }
}

Measured memory_bytes: 27840
#include<stdio.h>
#include<ctype.h>

int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		
		if(islower(ch)){
			printf("%c",toupper(ch));
		}else if(isupper(ch)){
			printf("%c",tolower(ch));
		}else{
			printf("%c",ch);
		}
			if(ch == '\n') break;
	}
}

Measured memory_bytes: 940
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back
#define inf 1000000000000000000

							
									//nestedcode
									
ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % M;
        a = (a * a)% M;
        b >>= 1;
    }
    return res;
}




int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s,t;
    ll n,i,a = 0;
  cin>>s>>t;
    n = s.length();
	    for(i=0;i<n;i++){
    	if(s[i]!=t[i])	a++;
	}
	cout<<a;
    
    
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int> a;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    a[s]=a[s]+1;
  }
  int x=0;
  map<string,int>::iterator it=a.begin();
  while(it!=a.end()){
    if(it->second >=x){
      x=it->second;
    }
    it++;
  }
  it=a.begin();
  while(it!=a.end()){
    if(it->second==x){
      cout<<it->first<<endl;
    }
    it++;
  }
  return 0;
}
    
  
  

Measured memory_bytes: 25216
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

int len;
char N[32];

uint32_t memo[32][2];

uint32_t search(int pos, int ismax) {
	uint32_t ret = 0;
	int i;
	if (pos >= len) return 0;
	if (memo[pos][ismax]) return ~memo[pos][ismax];
	for (i = 0; i <= 9 && (!ismax || i <= (N[pos] - '0')); i++) {
		uint32_t candidate = i + search(pos + 1, ismax && i == (N[pos] - '0'));
		if (candidate > ret) ret = candidate;
	}
	return ~(memo[pos][ismax] = ~ret);
}

int main(void) {
	if (scanf("%31s", N) != 1) return 1;
	len = strlen(N);
	printf("%"PRIu32"\n", search(0, 1));
	return 0;
}


Measured memory_bytes: 128
import collections

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)

cmb = 0
for x in c.values():
    cmb += x * (x - 1) // 2
    
for z in a:
    y = c.get(z)
    before = y * (y - 1) // 2
    after = (y - 1) * (y - 2) //2
    ans = cmb - before + after
    print(ans)

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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int L=A+B;
  int R=C+D;
  if(L<R){
    cout<<"Right"<<endl;
  }
  else if(L==R){
    cout<<"Balanced"<<endl;
  }
  else if(L>R){
    cout<<"Left"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

long long max(long long a,long long b){
  if(a > b){
    return a;
  }
  return b;
}

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

  int T,A;
  long long point[2] = {0,0};
  for(int i = 0;i < N;i++){
    scanf("%d%d",&T,&A);
    if(i == 0){
      point[0] = T;
      point[1] = A;
    }
    if(point[0] <= T && point[1] <= A){
      point[0] = T;
      point[1] = A;
    }else{
      counter = max((point[0]+T-1)/T,(point[1]+A-1)/A);
      point[0] = T*counter;
      point[1] = A*counter;
    }
  }

  printf("%lld\n",point[0]+point[1]);
  return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt() / 2;
        P[] aq = new P[100000];
        P[] bq = new P[100000];
        for (int i = 0;i < 100000;++i){
            aq[i] = new P();
            aq[i].index = i;
            bq[i] = new P();
            bq[i].index = i;
        }
        for (int i = 0;i < n * 2;++i){
            int d = sc.nextInt() - 1;
            if(i % 2 == 1){
                ++bq[d].num;
            }
            else{
                ++aq[d].num;
            }
        }
        ArrayList<P> aps = new ArrayList<>(Arrays.asList(aq));
        ArrayList<P> bps = new ArrayList<>(Arrays.asList(bq));
        aps.sort((a,b) -> b.num - a.num);
        bps.sort((a,b) -> b.num - a.num);
        if(n >= 2&&aps.get(0).index == bps.get(0).index){
            int i1 = aps.get(0).num + bps.get(1).num;
            int i2 = aps.get(1).num + bps.get(0).num;
            if(i1 < i2)i1 = i2;
            System.out.println(n * 2 - i1);
        }
        else{
            System.out.println(n * 2 - aps.get(0).num - bps.get(0).num);
        }

    }

    static class P{
        public int index = 0;
        public int num = 0;
    }


}





Measured memory_bytes: 65608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>

#define MOD 1000000007
#define SIMPLEMAX 1334000

#define MOD 1000000007

vll dp;
ll f(ll s)
{
    if(dp[s] < 0)
    {
        ll tmp = f(s - 1) + f(s - 3);
        tmp %= MOD;
        dp[s] = tmp;
        return tmp;
    }
    else
    {
        return dp[s];
    }
    
}


int main()
{
    ll S;
    INX(S);
    
    dp.resize(2001, -1);
    dp[0] = 1;
    dp[1] = dp[2] = 0;

    OUTX(f(S));


    return 0;
}

Measured memory_bytes: 3704
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = int(input().rstrip('\n'))
    b = int(input().rstrip('\n'))
    c = int(input().rstrip('\n'))
    d = int(input().rstrip('\n'))
    e = int(input().rstrip('\n'))

    m = min(a, b, c, d, e)

    print((n + m - 1) // m + 4)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<algorithm>
#define min(a,b) a<b?a:b
using namespace std;
vector<pair<int,int> > path[100005];//??´???????????¢
priority_queue<pair<long long int,int>,vector<pair<long long int,int> >,greater<pair<long long int,int> > > q1;
queue<int> q2;
long long int dis[100005];
bool used[100005];
int main(){
	int n,m,c;
	int i,j,k;
	long long int a,b,d;
	long long int sd=0;
	long long int s=20000000005;
	cin>>n>>m>>c;
	for(i=0;i<m;i++){
		cin>>a>>b>>d;
		a--,b--;
		path[a].push_back(make_pair(b,d));
		path[b].push_back(make_pair(a,d));
		sd+=d;
	}
	memset(dis,-1,sizeof(dis));
	q1.push(make_pair(0,0));
	while(!q1.empty()){
		b=q1.top().first,a=q1.top().second;
		q1.pop();
		if(dis[a]!=-1)continue;
		dis[a]=b;
		q2.push(a);
		for(i=0;i<path[a].size();i++){
			if(dis[path[a][i].first]!=-1)continue;
			q1.push(make_pair(b+path[a][i].second,path[a][i].first));
		}
	}
	while(!q2.empty()){
		a=q2.front();
		q2.pop();
		used[a]=true;
		for(i=0;i<path[a].size();i++){
			if(used[path[a][i].first])sd-=path[a][i].second;
		}
		s=min(s,dis[a]*c+sd);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 15356
#include <bits/stdc++.h>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF (1 << 30)
using namespace std;

int N, K, A;
vector<int> R, E[100000];
bool ans[100000];

int dfs(int v) {
  int depth = INF;
  REP(i, 0, E[v].size()) depth = min(depth, dfs(E[v][i]));
  if(depth == INF) depth = 0;
  if(depth < K) ans[v] = true;
  return depth + 1;
}

int main(void) {
  cin >> N >> K;
  REP(i, 0, N) {
    cin >> A;
    if(A >= 1) E[A - 1].push_back(i);
    else R.push_back(i);
  }

  REP(i, 0, N) ans[i] = false;
  REP(i, 0, R.size()) ans[R[i]] = true, dfs(R[i]);

  int cnt = 0;
  REP(i, 0, N) if(ans[i]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int N,K;
    cin>>N>>K;
    int a[N];
    for(int i=0;i<N;i++) cin>>a[i];
    int ans=0;
    for(int i=0;i<=min(K,N);i++)
    {
        for(int j=0;j<=min(K,N)-i;j++)
        {
            priority_queue<int,vector<int>,greater<int>> pq;
            int k;
            for(k=0;k<i;k++)
            {
                pq.push(a[k]);
            }
            k--;
            for(int l=0;l<j;l++)
            {
                if(N-1-l==k) break;
                pq.push(a[N-1-l]);
            }
            int res=K-i-j;
            while(res>0 && pq.size())
            {
                int v=pq.top();pq.pop();
                if(v>=0)
                {
                    pq.push(v);
                    break;
                }
                res--;
            }
            int cnt=0;
            while(!pq.empty())
            {
                cnt+=pq.top();
                pq.pop();
            }
            ans=max(ans,cnt);
            //cout<<ans<<" "<<i<<" "<<j<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
H = list(map(int, input().split()))

DP = [10 ** 9] * n
DP[0] = 0

for i in range(1, n):
    j = 1
    while i - j >= 0 and j <= k:
        DP[i] = min(DP[i], DP[i-j] + abs(H[i] - H[i-j]))
        j += 1
print(DP[-1])

Measured memory_bytes: 52448
import math
a, b, x = map(int, input().split())


if x <= (a*a*b)/2:
    h = (2*x)/(a*b)
    print(math.degrees(math.atan(b/h)))
else:
    t = (2*x)/(a*a) - b
    print(math.degrees(math.atan((b-t)/a)))


Measured memory_bytes: 3060
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = input()
for s in xrange(n):
  d = map( int, raw_input().split() )
  a = b = 0
  flag = True
  for e in d:
    if a < e: a = e
    elif b < e: b = e
    else: flag = False
  if flag: print "YES"
  else: print "NO"

Measured memory_bytes: 4196
N = int(input())
S = str(input())

cnt=0
if N%2==1:
    print('No')
else:
    for i in range(int(N/2)):
        if S[i]==S[int(N/2)+i]:
            cnt+=1
        else:
            print('No')
            break
    if cnt==int(N/2):
        print('Yes')

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv;

void main(){
	auto AB = ri!size_t();
	solve( AB[0] , AB[1] ).writeln();
	
	return;
}
auto solve( size_t A , size_t B ){
	if ( (B-1)%(A-1)==0 ){
		return (B-1)/(A-1);
	} else {
		return (B-1)/(A-1)+1;
	}
}




T[] ri( T = size_t )(){
	T[] ol;
	foreach( string elm ; readln().chomp().split() ){
		ol ~= elm.to!T();
	}
	return ol;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  ll A, B;
  cin >> A >> B;
  cout << A * B / __gcd(A, B) << endl;
  return 0;
}

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

int N, a[512];
using P = tuple<int, int, ll>;
map<P, int> done;

bool contain(int x, int s) {
  return (x & s) == x;
}

bool dfs(int cur, int lev, ll cnt) {
  if (lev < N && (cur & a[lev])) return 0;
  P p = P(cur, lev, cnt);
  if (done.count(p)) return 0;
  done[p]++;
  for (int i = 0; i < 16; i++) {
    ll c = (cnt >> (i*3)) & 7;
    cnt ^= c << (i*3);
    if (cur >> i & 1) c = 0;
    else c++;
    if (c == 7) return 0;
    cnt ^= c << (i*3);
  }
  if (lev == N) return 1;
  if (dfs(cur, lev+1, cnt)) return 1;
  if (contain(cur, 61166) && dfs(cur >> 1, lev+1, cnt)) return 1;
  if (contain(cur, 52428) && dfs(cur >> 2, lev+1, cnt)) return 1;
  if (contain(cur, 30583) && dfs(cur << 1, lev+1, cnt)) return 1;
  if (contain(cur, 13107) && dfs(cur << 2, lev+1, cnt)) return 1;
  if (contain(cur, 65520) && dfs(cur >> 4, lev+1, cnt)) return 1;
  if (contain(cur, 65280) && dfs(cur >> 8, lev+1, cnt)) return 1;
  if (contain(cur,  4095) && dfs(cur << 4, lev+1, cnt)) return 1;
  if (contain(cur,   255) && dfs(cur << 8, lev+1, cnt)) return 1;
  return 0;
}

void solve() {
  done.clear();
  cout << dfs(1632, 0, 0) << endl;
}

bool input() {
  cin >> N;
  if (N == 0) return 0;
  for (int i = 0; i < N; i++) {
    a[i] = 0;
    for (int j = 0; j < 16; j++) {
      int tmp;
      cin >> tmp;
      a[i] |= tmp << j;
    }
  }
  return 1;
}

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

  while (input()) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 27000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000003;
ll INF = 1000000099;

long long modpow(long long a, long long n, long long mod) {//a^n(mod)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;//次の準備
        n >>= 1;
    }
    return res;
}

const ll MAX = 1000003;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}


signed main(){
    ll q;
    cin>>q;
    COMinit();

    while(q--){
        ll x,d,n;
        cin>>x>>d>>n;
        if(d==0){
            cout << modpow(x,n,mod) << endl;
            continue;
        }
        
        if(n>=mod || (x*inv[d])%mod > (x*inv[d]+n-1)%mod){
            cout << 0 << endl;
        }else{
            cout << (modpow(d,n,mod)*fac[(x*inv[d]+n-1)%mod]*finv[(x*inv[d] -1)%mod] )%mod << endl;
        }
    }   
}

Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <cstdlib>
#include <math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF=100000;
int N;

int main(){

cin>>N;

int dp [200000];
for (int j=0;j<200000;++j)dp[j]=INF;
dp[0]=0;
int ku=0;
for (int i=0;i<=100000;i++){

	chmin(dp[i+1],dp[i]+1);
	for (int j=1;j<=6;++j){ku=pow(6,j);chmin(dp[i+ku],dp[i]+1);}
	for (int j=1;j<=5;++j){ku=pow(9,j);chmin(dp[i+ku],dp[i]+1);}

}

cout<<dp[N]<<endl;
}

Measured memory_bytes: 1276
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(n)]

g = [[0 for _ in range(2*n+2)] for _ in range(2*n+2)]

for (i, (a, b)) in enumerate(ab):
    fr = i+2
    g[0][fr] = 1
    for (j, (c, d)) in enumerate(cd):
        to = n+j+2
        g[to][1] = 1
        if a < c and b < d:
            g[fr][to] = 1

used = [False for _ in range(2 * n + 2)]
path = []
goal = 1
flow = [[0 for _ in range(2*n+2)] for _ in range(2*n+2)]


def bfs(v):
    used[v] = True
    for next in range(2 * n + 2):
        if g[v][next] == 0 or used[next]:
            pass
        elif next == goal:
            path.append(v)
            return True
        elif bfs(next):
            path.append(v)
            return True
    return False


ans = 0
while bfs(0):
    path.reverse()
    path.append(1)
    for i in range(len(path) - 1):
        g[path[i]][path[i + 1]] -= 1
        g[path[i + 1]][path[i]] += 1
    used = [False for _ in range(2 * n + 2)]
    path = []
    ans += 1
print(ans)


Measured memory_bytes: 9724
import numpy as np
N = int(input())
if N >= 2 :
    An = np.zeros(N+2, dtype=np.int)
    #An = [[] for _ in range(1,N+2)]
    #print(An)
    for s in range(1,N+1) :
        #print(s)
        if s%3 != 0 and s%5 != 0 :
            An[s] = int(s) 
            #print(s)
            #print(An[s])
    ans = np.sum(An)

else:
    ans = int(1)

print (int(ans))

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

using namespace std;

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

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll w[110];
int v[110];
ll dp[110][100010];
int n;
ll W;

int solveI(){
	for(int j=0; j<=100000; j++)
		dp[0][j] = INFLL;

	dp[0][0] = 0LL;
	dp[0][v[0]] = w[0];
		
	for(int i=1; i<n; i++){
		for(int j=0; j<v[i]; j++)
			dp[i][j] = dp[i-1][j];
		for(int j=v[i]; j<=100000; j++)
			dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);		
	}

	int ans = 0;

	for(int i=0; i<n; i++){
		for(int j=ans; j<=100000; j++){
			if( (dp[i][j]<=W) and (j>ans))
				ans = j;
		}
	}	
	
	return ans;
}

int main() {
	
	scanf("%d %lld", &n, &W);
	
	for(int i=0; i<n; i++)
		scanf("%lld %d", &w[i], &v[i]);

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


Measured memory_bytes: 80128
#include<stdio.h>
int main(void)
{
	for(;;){
		int i,p,h,w;
		scanf("%d %d\n",&h,&w);
		if(h==0&&w==0)
		break;
		for(i=0;i<h;i++){
			for(p=0;p<w;p++){
				printf("#");
				if(p==w-1)
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1824
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define ll long long
int n;
double p,a;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf",&a),p+=1.0/a;
	printf("%f",1.0/p);
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli h[100000] = {};

int main(void) {

	lli N;
	cin >> N;

	for (int i = 0; i < N; i++)
		cin >> h[i];

	lli ans = h[0];

	for (int i = 0; i < N - 1; i++) {
		ans += max(0LL, h[i + 1] - h[i]);
	}

	COUT(ans);

	return 0;
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll H, W, K;
  cin >> H >> W >> K;

  vector<string> cs;
  rep(i, H) cs.p_b(is());

  ll ans = 0;
  // W個の要素 {0, 1, ..., n-1} の部分集合の全探索
  for (ll bitH = 0; bitH < (1<<H); ++bitH){
    for (ll bitW = 0; bitW < (1<<W); ++bitW){
      ll black = 0;
      rep(h, H) rep(w, W){
        if (cs[h][w] == '#' && (!((bitH & (1<<h)) || (bitW & (1<<w))))){  // h番目のbitがtrueか
          black++;
        }
      }
      if (black == K) ans++;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 3628
while 1:
 n=int(input())
 if n==0:break;
 a=[]
 for _ in[0]*n:
  b=list(map(int,input().split()))
  b+=[sum(b)]
  a+=[b]
  for s in b:print("%5d"%s,end='')
  print()
 for c in zip(*a):print("%5d"%sum(c),end='')
 print()


Measured memory_bytes: 5592
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();
        int flg = 0;
        
        if(a>b){
            int temp = 0;
            temp = a;
            a = b;
            b = temp;
            flg = 1;
            
        }
        
        if(b>c){
            int temp = 0;
            temp = b;
            b = c;
            c = temp;
        }
        
        if(a>b){
            int temp = 0;
            temp = a;
            a = b;
            b = temp;
        }
        
        System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26180
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;string s;
    cin >> n >> s;
    vector<int> b(n+1);
    vector<int> w(n+1);
    b[0] = 0; w[0] = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '.') {
            w[i+1] = w[i]+1;
            b[i+1] = b[i];
        } else {
            b[i+1] = b[i]+1;
            w[i+1] = w[i];
        }
    }
    ll tmp = 0;
    ll ans = INF;
    REP(i,n+1) {
        tmp = b[i]+w[n]-w[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
int n,a[1005],b[1005],ans=0;
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {    
        cin>>a[i]>>b[i];
        ans+=b[i]-a[i]+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String s = scanner.next();
        if(a>=3200) {
        	System.out.println(s);
        }else {
        	System.out.println("red");
        }


    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  bool flag=false;
  FOR(i,1,10)FOR(j,1,10){
    if(n==i*j) flag=true;
  }
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll a) {
  int ans{};
  cout << ans << endl;
}

int main() {
  ll a;
  cin >> a;
  cout << a + a*a+ a*a*a << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
using namespace std;

int arr[15],used[15];

void dfs(int pre,int cur)
{
    if(cur<10&&arr[pre]<arr[cur])
    {
        used[cur]=1;
        dfs(cur,cur+1);
    }
    else if(cur<10&&arr[pre]>=arr[cur])
        dfs(pre,cur+1);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        bool judge=false;
        for(int i=0;i<10;i++)
            scanf("%d",&arr[i]);
        for(int i=0;i<10;i++)
        {
            memset(used,0,sizeof(used));
            used[i]=1;
            dfs(i,i+1);
            int pre=0;
            judge=false;
            for(int j=0;j<10;j++)
            {
                if(!used[j])
                {
                    if(pre>=arr[j])
                    {
                        judge=true;
                        break;
                    }
                    pre=arr[j];
                }
            }
            if(!judge)
            {
                printf("YES\n");
                break;
            }
        }
        if(judge) printf("NO\n");
    }
   return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h> 
using namespace std; 
  
#define PI 3.1415 
  
double circumference(int r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
} 
  
// driver function 
int main() 
{ 
  int r;
  cin>>r;
  cout <<circumference(r); 
  return 0; 
}  


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

int main(void){

    string S;
    cin>>S;
    vector<string> T = {
        "maerd",
        "remaerd",
        "esare",
        "resare"
    };
    reverse(S.begin(),S.end());
    while(S.size()){
        bool canDevide = false;
        for(int i=0;i<4;i++) {
            if (S.substr(0,T[i].size())==T[i]){
                canDevide = true;
                S.erase(0,T[i].size());
            }
        }
        if (!canDevide) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 512