akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end


N, M = get_ints
A = get_ints
X = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

if A.length == 1
  puts A[0].to_s * (N / X[A[0]])
else
  A.sort! { |a, b| (X[a] <=> X[b]).then { |x| x == 0 ? a <=> b : x } }
  ax = A.each_cons(2).map { |x, y| X[x] == X[y] ? nil : x }.compact
  ax.push(A.last) if X[A.last] != X[ax.last]

  min = ax[0]

  res = []
  test = ax[1..].map { |a| [a, X[a]] }
  test.unshift nil

  test.repeated_combination(7).each do |array|
    sum = array.map { |x| x ? x[1] : 0 }.sum
    div = (N - sum) / X[min]
    ama = (N - sum ) % X[min]
    if sum < N && ama == 0
      if array.compact.length == 0
        res.push min.to_s * div
      else
        xyz = array.compact.sort { |a, b| a[0] <=> b[0] }.reverse

        stock = ''
        min_used = false
        xyz.each do |a|
          if !min_used && min > a[0]
            stock += min.to_s * div
            min_used = true
          end
          stock += a[0].to_s
        end
        stock += min.to_s * div if !min_used

        res.push stock
      end
    end
  end

  puts res.sort { |a, b| (a.length <=> b.length).then { |x| x == 0 ? a <=> b : x } }.last
end



Measured memory_bytes: 17328
#include<cstdio>
using namespace std;
int main()
{
	int cnt1=0,cnt2=0;
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a%d==0)
	{
		cnt1=a/d;
	}
	else
	{
		cnt1=a/d+1;
	}
	if(c%b==0)
	{
		cnt2=c/b;
	}
	else
	{
		cnt2=c/b+1;
	}
	if(cnt2>cnt1)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
} 

Measured memory_bytes: 1660
#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
 
int main(){
  string s;
  cin >> s;
  int cnt = 0;
  //int lim = s.length()%2==0?s.length()/2:s.length()/2+1;
  //cout << s.length()/2 << endl;
  for(int i=0;i<s.length()/2;i++){
    if(!((s[i] == s[s.length()-1-i] && s[s.length()-1-i]!='(' && s[s.length()-1-i] != ')' && s[i] != '(' && s[i] != ')') || (s[i] == '(' && s[s.length()-1-i] == ')' || (s[i] == ')' && s[s.length()-1-i] == '('))))cnt++;
    //cout << s[i] << " " << s[s.length()-1-i] << endl;
  }
  //cout << s[s.length()/2] << endl;
  if(s.length()%2 != 0 && (s[s.length()/2] == '(' || s[s.length()/2] == ')'))cnt++;
 
  cout << cnt << endl;
return 0;
}

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

//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


 
int main(){
 
   
    ll n,ans;
    cin>>n;
       vi s(n+1);
        s.at(0)=1;
    s.at(1)=1;
    
    for(int i=2;i<=n;i++){
        s.at(i)=s.at(i-1)+s.at(i-2);
    }
    
    
    
    cout<<s.at(n)<<endl;
}
  


Measured memory_bytes: 3096
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const adjLists = Array.from(Array(n), () => []);
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => adjLists[i].push(e-1)));

  const d = [], f = [];
  dfs(adjLists, d, f);
  str = '';
  for (let i = 0; i < n; i++) {
    str += `${i + 1} ${d[i]} ${f[i]}\n`;
  }
  process.stdout.write(str);
})();

function dfs(adjLists, d, f) {
  const WHITE = 0, GRAY = 1, BLACK = 2;
  const size = adjLists.length;
  const color = Array.from(adjLists, () => WHITE);

  let time = 0;
  function visit(u) {
    color[u] = GRAY;
    d[u] = ++time;
    adjLists[u].forEach(v => {
      if (color[v] === WHITE) {
        visit(v);
      }
    });
    color[u] = BLACK;
    f[u] = ++time;
  }
  adjLists.forEach((e, u) => {
    if (color[u] === WHITE) visit(u);
  });
}



Measured memory_bytes: 16308
# 2019/10/22

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)<sum(b):
    print(-1)
    exit()
plus=[]
minus=[]
for aa,bb in zip(a,b):
    if aa==bb:continue
    if aa>bb:plus.append(aa-bb)
    else:minus.append(bb-aa)

plus.sort()
minus.sort(reverse=True)
p=0
m=sum(minus)
cnt=len(minus)
p=0
while p<m:
    p+=plus.pop()
    cnt+=1
print(cnt)


Measured memory_bytes: 18524
while True:
  n = int(raw_input())
  if not n: break

  s = [("%04d" % n)[i] for i in range(4)]
  if len(set(s)) == 1:
    print "NA"
    continue

  cnt = 0
  while n != 6174:
    cnt += 1
    s = [("%04d" % n)[i] for i in range(4)]
    n = int("".join(reversed(sorted(s)))) - int("".join(sorted(s)))
  print cnt

Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

void solve(){
	int n,a=0,b=0,c=0,d=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string s; cin>>s;
		if(s=="AC"){
			a++;
		}
		else if(s=="WA"){
			b++;
		}
		else if(s=="TLE"){
			c++;
		}
		else d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
}

int32_t main(){
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main()
{
    int H, W; cin >> H >> W;
    vector<string> A(H); for (auto& a : A) cin >> a;
    vector<vector<int>> R(H, vector<int>(W));
    for (int j = 0; j < W; j++) {
        if (A[0][j] == '#') break;
        R[0][j] = 1;
    }
    for (int i = 0; i < H; i++) {
        if (A[i][0] == '#') break;
        R[i][0] = 1;
    }
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            if (A[i][j] == '.') {
                R[i][j] = (R[i-1][j] + R[i][j-1]) % MOD;
            }
        }
    }
    cout << R[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll H, W;
  cin >> H >> W;
  auto elimh = mvec<bool>(H);
  auto elimw = mvec<bool>(W);
  auto vec = mvec<char>(H,W);
  for(auto&& i : vec) for(auto&& j : i){
    cin >> j;
  }
  rep(i,0,H){
    bool exist{};
    rep(j,0,W){
      if(vec[i][j] == '#') elimh[i] = 1;
    }
    if(exist == false) elimh.push_back(i); 
  }
  rep(i,0,W){
    bool exist{};
    rep(j,0,H){
      if(vec[j][i] == '#') elimw[i] = 1;
    }
  }
  rep(i, 0, H){
    if(elimh[i]){
      rep(j, 0, W){
        if(elimw[j]) cout << vec[i][j];
      }
      cout << rt;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
bool check(int a, int b , int c){
    if((a * a) == (b * b + c * c) ){ 
        return true ; 
    }
    return false ;
}
 
int main(){
    int i, a, b, c;
 
    cin >> i;
    for(int j = 0 ; j < i; j++){
        cin >> a >> b >> c;
        if(check(a, b, c) || check(b, c, a) || check(c, a, b) ){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<ld> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 1000000009;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };
int ddx[] = { -1,-2,1,-2,2,-1,2,1 }, ddy[] = { -2,-1,-2,1,-1,2,1,2 };

int main() {
	ll x,now=100;
	scanf("%lld",&x);
	for(int i=1;;i++)
	{
		now=(ll)((ld)now*101/100);
		if(now>=x)return !printf("%d",i);
	}
}

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

int main() {
  string s,t;cin>>s>>t;
  rep(i,s.size()) {
    if (s[i]!=t[i]) {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}
const double PI  = 3.14159265358979323846;

class Solution {
public:
	void solve() {
		double a, b, x;
		cin >> a >> b >> x;
		if(a*a*b/2 >= x){
			cout << setprecision(12)<<atan(a*b*b*0.5/x)/PI*180.0 << "\n";
		}else{
			cout << setprecision(12) << atan(2*(b-x/a/a)/a)/PI*180.0 <<"\n";
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=10005,mod=1000000000+7;
int Add(int a,int b){a+=b; return a>=mod ? a-mod : a;}
int Sub(int a,int b){a-=b; return a>=0 ? a : a+mod;}
int Mul(int a,int b){return 1LL*a*b%mod;}
void add(int &a,int b){a=Add(a,b);}
void sub(int &a,int b){a=Sub(a,b);}
void mul(int &a,int b){a=Mul(a,b);}
int qpow(int a,int b)
{
	int ans=1;
	while (b)
	{
		if (b&1) mul(ans,a);
		b>>=1;
		mul(a,a);
	}
	return ans;
}
int n;
void init()
{
	read(n);
}

void solve()
{
	if (n==1)
	{
		printf("0\n");
		return;
	}
	int ans=qpow(10,n);
	add(ans,qpow(8,n));
	sub(ans,qpow(9,n));
	sub(ans,qpow(9,n));
	printf("%d\n",ans);
}

int main()
{
	init();
	solve();
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int h[2], m[2];
  REP(i, 2) cin>>h[i]>>m[i];
  int temp = (h[1] - h[0]) * 60 + (m[1] - m[0]);
  int k;
  cin>>k;
  int ans = max(0, temp - k);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
N, M = map(int,input().split())
pl = [list(map(int,input().split())) for _ in range(N)]
cp =  [list(map(int,input().split())) for _ in range(M)]

for px,py in pl: 
  ans = 0
  cnt = 1
  minmd = 10**10
  for cx,cy in cp:
    nowmd = abs(px-cx) + abs(py-cy)
    if nowmd < minmd:
      ans = cnt
      minmd = nowmd
    cnt += 1
  print(ans)
    

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n),b(n),c(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	sort(ALL(a));
	sort(ALL(c));
	
	llong ans=0;
	REP(i,n){
		int cnta=lower_bound(ALL(a),b[i])-a.begin();
		int cntc=c.end()-upper_bound(ALL(c),b[i]);
		ans+=(llong)cnta*cntc;
	}
	
	cout<<ans<<endl;
	return 0;
}//解説参考.

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int a = 0;
		for (int i = 0; i < n; i++) {
			a += sc.nextInt();
		}
		System.out.println(a >= h ? "Yes":"No");
		sc.close();
	}
}

Measured memory_bytes: 46140
#include <stdio.h>

typedef long long ll;

int main(void)
{
  int h,w,i,j,ii,jj;
  int hh,ww;
  int a[55][55];
  int b[55][55],c[55][55];
  scanf("%d%d",&h,&w);
  for( i = 0; i < h; i++ ) {
    for( j = 0; j < w; j++ ) {
      scanf("%d",a[i]+j);
    }
  }
  for( i = 0; i < h; i++ ) {
    for( j = 0; j < w; j++ ) {
      scanf("%d",b[i]+j);
    }
  }
  scanf("%d%d",&hh,&ww);
  for( i = 0; i < hh; i++ ) {
    for( j = 0; j < ww; j++ ) {
      scanf("%d",c[i]+j);
    }
  }
  int res = -999999999;
  int dame = 1;
  for( i = 0; i <= h-hh; i++ ) {
    for( j = 0; j <= w-ww; j++ ) {
      int s = 0;
      int ok = 1;
      for( ii = 0; ii < hh; ii++ ) {
        for( jj = 0; jj < ww; jj++ ) {
          s += a[i+ii][j+jj];
          if( b[i+ii][j+jj] != c[ii][jj] ) ok = 0;
        }
      }
      if( ok ) {
        dame = 0;
        if( res < s ) res = s;
      }
    }
  }
  if( dame ) puts("NA");
  else printf("%d\n",res);
  return 0;
}  


Measured memory_bytes: 632
n,m=map(int,input().split())
ans=dict()
for i in range(m):
  a,b=map(int,input().split())
  if not(a in ans):
    ans[a]={b,}
  else:
    ans[a].add(b)
  if not(b in ans):
    ans[b]={a,}
  else:
    ans[b].add(a)    
flag=False

for i in ans[1]:
  if n in ans[i]:
    flag=True
    break
    

if flag:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 77452
N = int(raw_input())
F = []
for n in range(N):
    F.append([int(val) for val in raw_input().split(" ")])
P = []
for n in range(N):
    P.append([int(val) for val in raw_input().split(" ")])

max_val = None
for i_X in xrange(1, 2**10):
    c_i = [0]*N
    for i_pos in range(10):
        X_ijk = (i_X/(2**i_pos))%2
        for i_n in xrange(N):
            c_i[i_n] += F[i_n][i_pos] * X_ijk
    score = sum([P[i_n][c_i[i_n]] for i_n in xrange(N)])
    if (type(max_val) == type(None)) or (score > max_val):
        max_val = score

print max_val


Measured memory_bytes: 2820
while True:
    cnt=0
    n,x=map(int,input().split())
    if n == x == 0:
        break
    for a in range(1,n+1):
        for b in range(a+1,n+1):
            for c in range(b+1,n+1):
                cnt += 1 if a+b+c==x else 0
    print(cnt)



Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A, B, C; std::cin >> A >> B >> C;
  if ( A + B >= C ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){
    roll(1,2,4,3);
  }
  void roll_y(){
    roll(0,2,5,3);
  }
  void roll_x(){
    roll(0,1,5,4);
  }
  void roll(int i, int j, int k, int l){
    int t=f[i];
    f[i]=f[j];
    f[j]=f[k];
    f[k]=f[l];
    f[l]=t;
  }
};
 
bool eq(Cube c1,Cube c2){
  for(int i=0;i<6;i++)
    if(c1.f[i]!=c2.f[i]) return false;
  return true;
}
 
bool equal(Cube c1,Cube c2){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if(eq(c1,c2)) return true;
      c1.roll_z();
    }
    if(i%2==0)c1.roll_y();
    else c1.roll_x();
  }
  return false;
}
 
int main(){
  Cube c1,c2;
 
  for(int i=0;i<6;i++) cin >> c1.f[i];
  for(int i=0;i<6;i++) cin >> c2.f[i];
 
  if(equal(c1,c2)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    string S;
    getline(cin, S);
    vector<int> Sta(100);
    int ix=0;
    int OP1, OP2;
    for (int i=0; i<S.size(); i++) {
        switch (S.at(i)) {
            case ' ':
                break;
            case '+':
                OP2=Sta.at(--ix);
                OP1=Sta.at(--ix);
                Sta.at(ix++)=OP1+OP2;
                break;
            case '-':
                OP2=Sta.at(--ix);
                OP1=Sta.at(--ix);
                Sta.at(ix++)=OP1-OP2;
                break;
            case '*':
                OP2=Sta.at(--ix);
                OP1=Sta.at(--ix);
                Sta.at(ix++)=OP1*OP2;
                break;
            default:
                int n=0;
                while(' '!=S.at(i)) {
                    n *=10;
                    n +=S.at(i)-'0';
                    i++;
                }
                Sta.at(ix++)=n;
                break;
        }
    }
    cout <<Sta.at(--ix) <<endl;
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll k;
	cin>>k;
    ll s=7%k;
    for(ll i=1;i<1e7;i++)
    {
        if(s==0)
        {
            cout<<i;
            return;
        }
        else
            s=(s*10+7)%k;
            
    }
    cout<<"-1";
	return;
}
int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3620
#include <cstring>
#include <iostream>

using namespace std;

#define MAX_N 20
#define MAX_Q 200
#define MAX_M 2000

int n, q, A[MAX_N], m[MAX_Q];

bool dp[MAX_N + 1][MAX_M + 1];

int main()
{
	memset(dp, 0, sizeof(dp));

	cin >> n;

	for (int i = 0; i < n; i++) { cin >> A[i]; }

	cin >> q;

	for (int i = 0; i < q; i++) { cin >> m[i]; }

	dp[0][0] = true;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= MAX_M; j++)
		{
			if (j - A[i - 1] >= 0)
			{
				if (dp[i - 1][j] == true || dp[i - 1][j - A[i - 1]] == true)
				{
					dp[i][j] = true;
				}
			}
			else
			{
				if (dp[i - 1][j] == true)
				{
					dp[i][j] = true;
				}
			}
		}
	}

	for (int i = 0; i < q; i++)
	{
		cout << (dp[n][m[i]] ? "yes" : "no") << endl;
	}

	return 0;
}

// Time : O ( n * MAX_M )

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

int main() {
  int K;
  cin >> K;
  string A;
  cin >> A;
  int S;
  S = A.size();
  if (S <= K)
    cout << A << endl;
  else {
    for (int i = 0; i < K; i++) {
      cout << A.at(i);
      if (i + 1 == K)
        cout << "..." << endl;
    }
  }
}

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

const int INF = 1 << 20;
int A, B, C;
int dp[210][210][210];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> A >> B >> C;
  fill_n((int*)dp, 210*210*210, INF);
  dp[A][B][C] = 0;
  for (int i = 0; i < 200; i++) {
    for (int j = 0; j < 200; j++) {
      for (int k = 0; k < 200; k++) {
        if (dp[i][j][k] == INF) continue;
        dp[i+0][j+1][k+1] = min(dp[i+0][j+1][k+1], dp[i][j][k]+1);
        dp[i+1][j+0][k+1] = min(dp[i+1][j+0][k+1], dp[i][j][k]+1);
        dp[i+1][j+1][k+0] = min(dp[i+1][j+1][k+0], dp[i][j][k]+1);

        dp[i+2][j+0][k+0] = min(dp[i+2][j+0][k+0], dp[i][j][k]+1);
        dp[i+0][j+2][k+0] = min(dp[i+0][j+2][k+0], dp[i][j][k]+1);
        dp[i+0][j+0][k+2] = min(dp[i+0][j+0][k+2], dp[i][j][k]+1);
      }
    }
  }
  int ans = INF;
  for (int i = max({A,B,C}); i < 200; i++) {
    ans = min(ans, dp[i][i][i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 36480
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    string s;
    cin >> s;
    int ans=0;
    int n=0;
    rep(i,3){
        if(s.at(i)=='R')n++;
        else if(s.at(i)=='S')n=0;
        ans=max(ans,n);
    }
    cout << ans << endl;
    
} 
    

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

int dp[100001];

bool whoWins( int a[],int n, int k){

    if(k==0){
        return true;
    }

    if(k<0){
        return false;
    }

    if(dp[k]!=-1){
        return dp[k];

    }  

    bool ans=true;


    for(int i=0;i<n;i++){
        ans=ans&&(!whoWins(a,n,k-a[i]));

    }

    return dp[k]=ans;


}
 
int main() {
    
    int n,k;
    cin>>n>>k;
    int a[n];
    memset(dp,-1,sizeof(dp));


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

    if(whoWins(a,n,k)){
        cout<<"Second";
    }else{
        cout<<"First";
    }




}


Measured memory_bytes: 11800
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		int N = in.nextInt();
		int K = in.nextInt();
		int[] count = new int[N];
		for (int i = 0; i < N; i += 1) {
			count[in.nextInt() - 1] += 1;
		}
		Arrays.sort(count);
		int sum = 0;
		for (int i = 0; i < N - K; i += 1) {
			sum += count[i];
		}
		out.println(sum);
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


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

int main(){
  int h,n;
  cin >> h >> n;
  VI a(n);
  rep(i,n) cin >> a[i];
  
  int sum=0;
  rep(i,n){
    sum += a[i];
  }
  
  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int a,b;
  char op;

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

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

int main() {
  int N, flag;
  flag = 0;
  cin >> N;
  for(int i = 1; i < 10; i++){
    for(int n = 1; n < 10; n++){
      if( N == i * n){
        flag = 1;
        break;
      }
    }
  }
  if ( flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:char,
    }
    if a=='A' {println!("T") }
    if a=='T' {println!("A") }
    if a=='G' {println!("C") }
    if a=='C' {println!("G") }
}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    typedef long long int lint;
    const lint M = 1e9 + 7;
    int n, m;
    cin >> n >> m;

    vector<bool> broken(n+1, false);
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        broken[x] = true;
    }

    vector<lint> dp(n+1, 0);
    dp[n] = 1;
    for (int i = n-1; i >= 0; --i) {
        if (i+1 <= n && !broken[i+1])
            dp[i] = (dp[i] + dp[i+1])%M;
        if (i+2 <= n && !broken[i+2])
            dp[i] = (dp[i] + dp[i+2])%M;
        
    }

    cout << dp[0] << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

vi c;
vvi graph;

int K;
vll sub;
vll cnt;
vll ans;


ll solve(int u, int p) {
    ++K;
    sub[u] = 1;
    ll save = cnt[c[u]];

    for (auto neigh: graph[u]) {
        if (neigh == p) continue;
        ll prev = K - cnt[c[u]];
        sub[u] += solve(neigh, u);
        ll now = K - cnt[c[u]];
        ans[c[u]] -= (now-prev) * (now-prev-1)/2;
    }

    cnt[c[u]] = save + sub[u];
    return sub[u];
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    K = 0;
    c = vi(n+1);
    graph = vvi(n+1);
    ans = vll(n+1, (ll)n * (n-1)/2);
    sub = vll(n+1);
    cnt = vll(n+1);

    for (int i = 1; i <= n; ++i) {
        cin >> c[i];
        ans[c[i]] += 1;
    }
    
    for (int i = 0; i < n-1; ++i) {
        int a,b; cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    solve(1,0);
    for (int i = 1; i <= n; ++i) {
        ll diff = K - cnt[i];
        ans[i] -= diff * (diff-1)/ 2;
    }
    
    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << '\n';
    }
    return 0;
}



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

int k(int a){
	int g=1;
	for(int i=2; i*i<=a; i++){
		int d=1;
		while(a%i==0){
			d++;
			a/=i;
			//cout<<"a"<<a<<" ";
			//cout<<i<<" ";
		}
		g*=d;
	}
	if(a!=1) g*=2;
	return g;
}




int main(){
	int n; cin>>n;
	int ans=0;
	for(int c=1;c<n;c++){
		//cout<<n-c<<"n-c ";
		ans+=k(n-c);
		//cout<<k(n-c)<<"k"<<endl;
	}


	cout<<ans<<endl;
}

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

int main(){
  int n;
  cin >> n;
  map<int64_t,int>kami;
  int64_t a;
  for(int i=0;i<n;i++){
    cin >> a;
    kami[a]=(kami[a]==1)?0:1;
  }
  int ans=0;
  for(auto x:kami)
    if(x.second==1)
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9808
import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if (line[i],line[i+1]) in d:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, k, ans;
int main() {
    vector<ll> s, a, b;
    cin >> n >> m >> k;
    REP(i, n){
        ll c;
        cin >> c;
        a.push_back(c);
    }
    REP(i, m){
        ll c;
        cin >> c;
        b.push_back(c);
    }
    ll now = 0;
    s.push_back(MINF);
    REP(i, m){
        now += b[i];
        s.push_back(now);
    }
    s.push_back(INF);
    now = 0;
    ll i1 = upper_bound(ALL(s), k) - s.begin() - 1;
    ans = max(ans, i1);
    //cout << ans << endl;
    REP(i, n){
        now += a[i];
        if (k - now < 0) break;
        ll it = upper_bound(ALL(s), k - now) - s.begin() - 1;
        //cout << k - now << " " << s[it] << endl;
        ans = max(ans, it + i + 1);
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9556
#include <iostream>
#include <map>
#include <set>
#include <string>
#include<string.h>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

vector<long long> xray,yray;
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector<long long> x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        xray.push_back(x[i]);
        yray.push_back(y[i]);
    }
    sort(xray.begin(),xray.end());
    sort(yray.begin(),yray.end());

    ll ans=1LL*(xray[n-1]-xray[0])*(yray[n-1]-yray[0]);

    for(int x1=0;x1<n;x1++){
        for(int x2=x1+1;x2<n;x2++){
            for(int y1=0;y1<n;y1++){
                for(int y2=y1+1;y2<n;y2++){
                    ll lx=xray[x1],rx=xray[x2];
                    ll uy=yray[y2],dy=yray[y1];
                    int num=0;
                    for(int i=0;i<n;i++){
                        if(x[i]>=lx and x[i]<=rx&&y[i]<=uy&&y[i]>=dy){
                            num++;
                        }
                    }
                    if(num>=k) ans=min(ans,1LL*(rx-lx)*(uy-dy));
                }
            }
        }
    }
    printf("%lld\n",ans);
  // cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N, M, count;
    cin >> N >> M;
    count = 0;
    
    for (int i = 0; i < N; i++) {
        
        count += (N-1);
    }

    for (int i = 0; i < M; i++) {

        count += (M-1);
    }

    cout << count/2 << endl;
}

Measured memory_bytes: 256
S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int h, w, i, j;

	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w ==0)
			break;
		for(i=0; i<h; i++){
			for(j=0; j<w; j++)
				printf("#");
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <tuple>
using namespace std;
template<class T>
bool equal(T x, T y) { return x==y;}

template<>
bool equal(const char* x, const char* y) {return std::strcmp(x, y);}

template<class Iterator, class Compare>
void selection_sort(Iterator first, Iterator last, Compare comp)
{
    for(Iterator p = first; p != last; ++p)
    {
        Iterator min_position = p;
        for(Iterator q = p; q != last; ++q)
        {
            if(comp(*q, *min_position))
                min_position = q;
        }
        auto tmp = *min_position;
        *min_position = *p;
        *p = tmp;
    }
}

int main()
{
    
    int N; cin >> N;
    string s, t; cin >> s >> t;
    bool f = false;
    for(int i=0; i<N; ++i){
        
        if(s[i]==t[0]){
            for(int j=0; j<N; ++j){
                if(s[i+j] != t[j]) break;
                if(i+j==N-1){
                    cout << i+N << endl;
                    return 0;
                }
            }
            
        }if(f) break;
    }
    cout << 2*N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    string X;
    cin >> X;
    int mod = 0;
    for (int i = 0; i < N; i++) {
        if(X[i] == '1') mod++;
    }

    vector<int> tl(N);
    tl[N-1] = 1;
    vector<int> tu(N);
    tu[N-1] = 1;
    for (int i = N-2; i >= 0; i--) {
        tu[i] = tu[i+1] * 2 % (mod+1);
        if(mod > 1){
            tl[i] = tl[i+1] * 2 % (mod-1);
        }
    }

    int ku = 0;
    int kl = 0;
    for (int i = N-1; i >= 0; i--) {
        if(X[i] == '1'){
            ku += tu[i];
            ku = ku % (mod+1);
        }
    }
    if(mod > 1){
        for (int i = N-1; i >= 0; i--) {
            if(X[i] == '1'){
                kl += tl[i];
                kl = kl % (mod-1);
            }
        }
    }



    int cnt;
    int tmp, ans;
    for (int i = 0; i < N; i++) {
        if(X[i] == '1'){
            if(mod == 1){
                printf("%d\n", 0);
                continue;
            }
            tmp = ((mod-1) + kl - tl[i]) % (mod-1);
        }
        else{
            tmp = ((mod+1) + ku + tu[i]) % (mod+1);
        }
        if(tmp == 0){
            printf("%d\n", 1);
            continue;
        }
        cnt = 0;
        while(true){
            ans = __builtin_popcount(tmp);
            cnt++;
            if(ans == 0){
                printf("%d\n", cnt);
                break;
            }           
            tmp = tmp % ans;

        }


    }

}

Measured memory_bytes: 5240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int x=sc.nextInt();
			int y=sc.nextInt();
			int s=sc.nextInt();
			if((x==0&&y==0)&&s==0) break;
			int max=0;
			for(int i=1;i<s;++i){
				for(int j=1;j<s;++j){
					if((((i*(100+x))/100)+((j*(100+x))/100)==s)&&(max<(i*(100+y))/100+(j*(100+y))/100)){
						max=(i*(100+y))/100+(j*(100+y))/100;
					}
				}
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 29132
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <queue>

using namespace std;

static const int MAX = 100;

struct node{int key, fi, fj;
        bool operator<(const node& rhs)const
    {
        return key > rhs.key;
    }
};

int n;
int A[MAX][MAX];
priority_queue<node> p_q;
int check[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> A[i][j];
            if(A[i][j] != -1){
                p_q.push({A[i][j], i, j});
            }
        }
    }
    fill(check, check+n, 0);
    
    
    int cnt = 0;
    int ans = 0;
    int now_id = 1;
    while(!p_q.empty()){
        int fi = p_q.top().fi;
        int fj = p_q.top().fj;
        int key = p_q.top().key;
        p_q.pop();
        
        if(!check[fi] && !check[fj]){
            check[fi] = now_id;
            check[fj] = now_id;
            ans+=key;
        }
        else if(!check[fi]){
            cnt = 0;
            int a = check[fj];
            for(int i=0; i<n; i++){
                if(check[i] == a){
                    check[i] = now_id;
                    cnt++;
                }
            }
            check[fi] = now_id;
            cnt++;
            ans+=key;
        }
        else if(!check[fj]){
            cnt = 0;
            int a = check[fi];
            for(int i=0; i<n; i++){
                if(check[i] == a){check[i] = now_id;
                cnt++;
                }
            }
            check[fj] = now_id;
            cnt++;
            ans+=key;
        }
        else if(check[fi] != check[fj]){
            int a = check[fj];
            int b = check[fi];
            cnt = 0;
            for(int i=0; i<n; i++){
                if(check[i] == a){
                    check[i] = now_id;
                    cnt++;
                }
            
            }
            for(int i=0; i<n; i++){
                if(check[i] == b){
                    check[i] = now_id;
                    cnt++;
                }
            }
            ans+=key;
        }
        if(cnt>=n)break;
        now_id++;
    }
    
    cout << ans << endl;
    
    return 0;
}



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

using namespace std;

const int mod = 1e9 + 7;

void solve(void)
{
	string s;
	cin >> s;
	vector<int> dp(13);
	dp[0] = 1;
	for (char c : s)
	{
		vector<int> nx(13);
		for (int i = 0; i < 13; i++)
		{
			if (c == '?')
			{
				for (int j = 0; j < 10; j++)
				{
					nx[(i*10 + j) % 13] += dp[i];
					nx[(i*10 + j) % 13] %= mod;
				}
			}
			else
			{
				nx[(i*10 + c - '0') % 13] += dp[i];
				nx[(i*10 + c - '0') % 13] %= mod;
			}
		}
		swap(dp, nx);
	}
	cout << dp[5] << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,s,i,j;
  while(scanf("%d %d",&n,&s),n||s){
    int c=0,d[20001];
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
      for(j=i;j;j--){
	if(d[i]+d[j-1]>s)c++;
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 1000;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
array<array<int, SZ>, D> S;

struct State {
	array<int, SZ> last = {};
	array<int, D> ans;
	int score = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		rep(i, SZ) score -= C[i] * (d + 1 - last[i]);
	}

	int next_eval(int d, int t){
		int res = score;
		res += S[d][t];
		rep(i, SZ){
			if (i != t) res -= C[i] * (d + 1 - last[i]);
		}
		return res;
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.last[t] = d + 1;
		res.update_score(d, t);
		return res;
	}

	array<int, D> answer() {
		return ans;
	}
};

array<int, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.next_eval(d, t) > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (int i : ans) cout << i + 1 << endl;

	return 0;
}


Measured memory_bytes: 6832
#include <bits/stdc++.h>
#include <unistd.h>
#include <stdio.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}


int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;




}

Measured memory_bytes: 256