akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
#define eb(a) emplace_back(a)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 4e5 + 5;
int t;
int a[N];
int main()
{
	ll n, k;
	while (cin >> n >> k)
	{
		ll re = n / k;
		n -= re * k;
		//set<int> st;
		map<ll, int> mp;
		mp[n]++;
		while (1)
		{
			n = abs(n - k);
			if (mp[n] > 0)break;
			mp[n]++;
		}
		cout << mp.begin()->first << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll insort(vec &a,ll n){
  Loop(i,1,n){
    ll v=a[i];
    ll j=i-1;
  while(j>=0&&a[j]>v){
    a[j+1]=a[j];
    j--;
  }
    a[j+1]=v;
    loop(j,n){
      cout<<a[j];
      if(j<n-1)cout<<" ";
    }
    if(i<n-1)putout("");
  }
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n)cin>>a[i];
  loop(i,n){
    cout<<a[i];
    if(i<n-1)cout<<" ";
  }
  putout("");
  insort(a,n);
  if(n>1)cout<<""<<endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 200; u++)
	{
		int n;

		cin >> n;
		if (n == -1)
		{
			break;
		}

		if (n <= 10)
		{
			cout << 3130 << endl;
		}
		else if (n <= 20)
		{
			cout << 4280 - (1150 + ((n - 10) * 125)) << endl;
		}
		else if (n <= 30)
		{
			cout << 4280 - (2400 + ((n - 20) * 140)) << endl;
		}
		else
		{
			cout << 4280 - (3800 + ((n - 30) * 160)) << endl;
		}
	}
}



Measured memory_bytes: 3008
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    string s;
    int K;

    void input() {
        cin >> s;
        cin >> K;


    }

    void solve() {
        input();

        int n = s.size();

        vector<vector<string> > vs(26);
        for (char c = 'a'; c <= 'z'; c++) {
            for (int i = 0; i < n; ++i) {
                if (s[i] == c) {
                    for (int k = 1; i + k - 1 < n && k <= K; ++k) {
                        string tmp = s.substr(i, k);
                        vs[c - 'a'].push_back(tmp);
                    }
                }
            }
        }

        int rest = K;
        for (int i = 0; i < 26; ++i) {
            sort(all(vs[i]));
            vs[i].erase(unique(all(vs[i])), vs[i].end());
            if (vs[i].size() >= rest) {
                cout << vs[i][rest - 1] << endl;
                return;
            } else {
                rest -= vs[i].size();
            }
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1664
n, m = map(int, input().split())
ans = [0]*(n+1)
for _ in [0]*m:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    if a==1:
        ans[b] += 1
    elif b==n:
        ans[a] += 1
if 2 in set(ans):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 11984
#include <stdio.h>
long long int minx(long long int v[],int n){
	int i,j,k;
	long long int tmp;
	tmp=v[0];
	for(i=1;i<=n-1;i++){
		if(tmp>v[i])
		tmp=v[i];}
		return tmp;}
int maxx(int v[],int n){
	int i,j,k,tmp;
	tmp=v[0];
	for(i=1;i<=n-1;i++){
		if(tmp<v[i])
		tmp=v[i];}
		return tmp;}
int max(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2>tmp)
	tmp=n2;
	if(n3>tmp)
	tmp=n3;
	return tmp;}
int max2(int n1,int n2){
	int tmp;
	tmp=n1;
	if(n2>tmp)
	tmp=n2;
	return tmp;}
int min3(int n1,int n2,int n3){
	int tmp;
	tmp=n1;
	if(n2<tmp)
	tmp=n2;
	if(n3<tmp)
	tmp=n3;
	return tmp;}
int min2(int n1,int n2){
	int tmp;
	tmp=n1;
	if(n2<tmp)
	tmp=n2;
	return tmp;}
long long int abs(long long int n){
	if(n>=0)
	return n;
	else return(-1)*n;
}
int main(void)
{int N,A,M,B,j,i,k,H,W,l,m,flag;
	long long int X,Y;
	scanf("%lld%lld",&X,&Y);
	flag=0;
	m=0;
	for(i=0;i<=1000;i++){
		if(Y>=X){
		X*=2;
		m+=1;
		}}
	
				printf("%d",m);
				
			

	return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 200050;

int n;
char str[maxn];

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%s",str+1);
	n = strlen(str+1);
	ll Ans = 0; int num = 0;
	fd(i,n,1) if(str[i] == 'B') {Ans += (n-i-num); ++ num;}
	pf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int A,B,ans=0;
int main(){
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    /*stringstream ss;
    ss << i;
    string s=ss.str();*/
    string s;
    s=to_string(i);
    if(s[0]==s[4] && s[1]==s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <numeric>
#include <utility>

namespace n91 {

void main_() {
  static constexpr u32 zero = static_cast<u32>(0);
  usize n;
  std::cin >> n;
  std::vector<u32> a(n);
  for (auto &e : a) {
    std::cin >> e;
  }
  const u32 sum = std::accumulate(a.cbegin(), a.cend(), zero);
  u32 le = zero, lo = zero, re = zero, ro = zero;
  for (const auto i : rep(0_z, n)) {
    if (i % 2_z == 0_z) {
      re += a[i];
    } else {
      ro += a[i];
    }
  }
  for (const auto i : rep(0_z, n)) {
    if (i % 2_z == 0_z) {
      re -= a[i];
      std::cout << sum - (le + ro) * static_cast<u32>(2) << std::endl;
      le += a[i];
    } else {
      ro -= a[i];
      std::cout << sum - (lo + re) * static_cast<u32>(2) << std::endl;
      lo += a[i];
    }
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int cnt[111111];

int main() {
	scanf("%d", &n);
	REP(i, n) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	int ans = 0;
	for(int X = 1; X <= 100000; X++) {
		ans = max(ans, (cnt[X]+cnt[X-1]+cnt[X+1]));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

 int h[100];

int calc(int n,int m){
  int mn=BIG;
  int l=n;
  int ans=0,b=0;
  for(int i=n;i<m;i++){
    if(h[i]!=0) b=1;
  }
  if(b==0) return ans;
  
  for(int i=n;i<m;i++){
    if(h[i]==0){b=0;break;}
  }
  if(b==1){
    for(int i=n;i<m;i++){
      mn=min(mn,h[i]);
    }
    for(int i=n;i<m;i++){
      h[i]-=mn;
    }
    ans+=mn;
  }
  /*cout<<"("<<n<<" "<<m<<")"<<endl;
  for(int i=n;i<m;i++){
    cout<<h[i]<<" ";}
    cout<<endl;*/
  for(int i=n;i<m;i++){
    if(h[i]==0){ans+=calc(l,i);l=i+1;}
  }
  ans+=calc(l,m);
  return ans;
}
    
  

int main(){
  int n,ans=0;
  cin>>n;
  rep(i,n){
    cin>>h[i];
  }
  int mx=0,c=0;
  ans+=calc(0,n);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def ABC_132_A():
    S = input()
    if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':

    ABC_132_A()

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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

const D EPS = 1e-8;

inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b,c) > EPS)return 1;
  if(cross(b,c) < -EPS)return -1;
  if(dot(b,c) < -EPS)return 2;
  if(abs(b)+EPS < abs(c))return -2;
  return 0;
}

inline D seg_p_dis(L a, P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

inline bool is_cp(L a, L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline D seg_seg_dis(L a, L b){
  D res = 1e10;
  res = min(res, seg_p_dis(a,b.fs));
  res = min(res, seg_p_dis(a,b.sc));
  res = min(res, seg_p_dis(b,a.fs));
  res = min(res, seg_p_dis(b,a.sc));
  return res;
}

inline bool isCross(L a, Poly p){
  int n = p.size();
  rep(i,n){
    if(is_cp(a, L(p[i],p[(i+1)%n])))return true;
  }
  return false;
}

inline bool isIn(L a, Poly p){
  P x = a.fs;
  rep(i,p.size())if(ccw(p[i],p[(i+1)%p.size()],x) == -1)return false;
  return true;
}

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;
    L line;
    {
      int x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2;
      line = L(P(x1,y1),P(x2,y2));
    }

    vector<Poly> obj(n);
    vector<D> h(n);

    rep(i,n){
      int x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2 >> h[i];
      obj[i].push_back(P(x1,y1));
      obj[i].push_back(P(x2,y1));
      obj[i].push_back(P(x2,y2));
      obj[i].push_back(P(x1,y2));
    }

    bool f = false;
    rep(i,n){
      if(isCross(line,obj[i]) || isIn(line,obj[i])){
	f = true;
      }
    }
    if(f){
      cout << fixed << setprecision(5) << 0 << endl;
      continue;
    }

    D l = 0, r = 1000;
    rep(azu,100){
      D mid = (l+r)/2;
      
      bool f = true;
      rep(i,n){
	D dis = 1e10;
	rep(j,4){
	  dis = min(dis, seg_seg_dis(line, L(obj[i][j],obj[i][(j+1)%4])));
	}
	if(h[i] < mid){
	  if(sqrt(dis*dis + (mid-h[i])*(mid-h[i])) < mid)f = false;
	}else{
	  if(dis < mid)f = false;
	}
	if(!f)break;
      }

      if(f)l = mid;
      else r = mid;
    }
    cout << fixed << setprecision(5) << l << endl;
  }
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define test int t; cin>>t; while(t--)
int main()
{
    ll n,x;
    cin>>n>>x;
    ll arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if((arr[i-1]+arr[i])>x)
        {
            ll rem=(arr[i-1]+arr[i])-x;
            ans+=rem;
            arr[i]=arr[i]-rem;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4368
import java.util.*;
import java.io.*;

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

        int n = Integer.parseInt (f.readLine());
        StringTokenizer st=new StringTokenizer(f.readLine());
        int []arr=new int[n];
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt (st.nextToken());
        }

        int dp[]=new int[n];
        dp[1]=Math.abs(arr[1]-arr[0]);
        if(n>2)
            dp[2]=Math.min(Math.abs(arr[2]-arr[0]),Math.abs(arr[2]-arr[1])+dp[1]);
        for(int i=3;i<n;i++){
            dp[i]=Math.min(Math.abs(arr[i]-arr[i-1])+dp[i-1],Math.abs(arr[i]-arr[i-2])+dp[i-2]);
        }

        System.out.println(dp[n-1]);



        f.close();
    }

}


Measured memory_bytes: 32156
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

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

int ans[maxn],vis[maxn],f;

int main()
{
	int n=read(),m=read();
	if(n==1&&m==0) {puts("0"); return 0;}
	for(int i=1;i<=m;i++)
	{
		int a=read(),b=read();
		if(vis[a])
		{
			if(ans[a]==b) continue;
			else f=1;
		}
		else
		{
			ans[a]=b;
			vis[a]=1;
		}
	}
	if(vis[1]==1&&ans[1]==0&&n==1) {puts("0"); return 0;}
	else if(vis[1]==1&&ans[1]==0) {puts("-1"); return 0;}
	if(f==1) {puts("-1"); return 0;}
	if(vis[1]) cout<<ans[1];
	else cout<<1;
	for(int i=2;i<=n;i++)  if(vis[i]) cout<<ans[i]; else cout<<0;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>

using namespace std;
using lli = long long int;

lli a[301] = {};
lli A[301][300 * 303] = {};
lli B[301][300 * 303] = {};

const lli mod = 998244353;

int main(void) {

	lli N;
	cin >> N;

	lli total = 1,sum = 0;

	for (lli i = 0; i < N; i++) {
		cin >> a[i];
		total *= 3;
		total %= mod;
		sum += a[i];
	}

	A[0][0] = 1;
	B[0][0] = 1;

	for (lli i = 0; i < N; i++) {
		for (lli j = 0; j < 300 * 301; j++) {
			A[i + 1][j] += 2 * A[i][j];
			A[i + 1][j] %= mod;

			A[i + 1][j + a[i]] += A[i][j];
			A[i + 1][j + a[i]] %= mod;


			B[i + 1][j] += B[i][j];
			B[i + 1][j] %= mod;

			B[i + 1][j + a[i]] += B[i][j];
			B[i + 1][j + a[i]] %= mod;
		}
	}

	lli ans1 = 0,ans2 = 0;

	for (lli i = 0; i < 300*301; i++) {
		if (sum <= i * 2) {
			ans1 += A[N][i];
            ans1 %= mod;
		}
	}

	if (sum % 2 == 0) {
		ans2 = B[N][sum/2];
	}

	cout << (((total - 3 * ans1) % mod + 3 * ans2) % mod + mod) % mod << endl;

}


Measured memory_bytes: 427008
H, W = map(int, input().split())

result = H * W
S = [None] * 3

"""
+--------------+
| S0 | S1 | S2 |
+--------------+
"""
if W >= 3:
    S_min = H * (W // 3)
    S_max = H * ((W + 2) // 3)
    result = min(result, S_max - S_min)

"""
+----+
| S0 |
+----+
| S1 |
+----+
| S2 |
+----+
"""
if H >= 3:
    S_min = W * (H // 3)
    S_max = W * ((H + 2) // 3)
    result = min(result, S_max - S_min)

"""
+----+----+
| S0 |    |
+----+ S2 |
| S1 |    |
+----+----+
"""
for w in range(1, W):
    S[0] = w * (H // 2)
    S[1] = w * ((H + 1) // 2)
    S[2] = (W - w) * H
    result = min(result, max(S) - min(S))

"""
+----+----+
| S0 | S1 |
+----+----+
|   S 2   |
+---------+
"""
for h in range(1, H):
    S[0] = h * (W // 2)
    S[1] = h * ((W + 1) // 2)
    S[2] = (H - h) * W
    result = min(result, max(S) - min(S))

print(result)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static int ans = Integer.MAX_VALUE;
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st.nextToken());
        int m = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken());
        book[] bookArr = new book[n];
        for (int i=0; i<n; i++){
            st = new StringTokenizer(br.readLine());
            bookArr[i] = new book(st, m);
        }
        dfs(n,m,bookArr,0, x, new int[m], 0);
        if (ans==Integer.MAX_VALUE)
            ans=-1;
        System.out.println(ans);
    }

    public static void dfs(int n, int m, book[] books, int pos, int X, int[] curSkill, int cost){
        if (pos==n){
            boolean valid=true;
            for (int i=0; i<m; i++){
                if (curSkill[i]<X){
                    valid=false;
                    break;
                }
            }
            if (valid){
                ans = Math.min(ans,cost);
            }
            return;
        }

        dfs(n,m,books,pos+1,X,curSkill,cost);
        int[] curSkillNew = curSkill.clone();

        for (int i=0; i<m; i++){
            curSkillNew[i]+=books[pos].skill[i];
        }
        dfs(n,m,books,pos+1,X,curSkillNew,cost+books[pos].cost);

    }

    public static class book{
        int cost;
        int[] skill;
        book(StringTokenizer st, int m){
            cost = Integer.parseInt(st.nextToken());
            skill = new int[m];
            for (int i=0; i<m; i++)
                skill[i] = Integer.parseInt(st.nextToken());
        }
    }
}


Measured memory_bytes: 34492
import numpy as np
import itertools as it

n = int(input())
o = []
for _ in range(n):
    x,y = list(map(int, input().split()))
    o.append([x,y])
o = np.array(o)

a = list(it.permutations(list(range(n))))
b = list(it.combinations(list(range(n)), 2))
c = []
for bb in b:
    xx,yy = o[list(bb)]
    zz = xx - yy
    delta = np.sqrt(zz[0]**2 + zz[1]**2)
    c.append(delta)

ans = sum(c)*(n-1)/len(c)
print(ans)

Measured memory_bytes: 17064
using System;

namespace GCD
{
    class Program
    {
        private static int Gcd(int a, int b)
        {
            if (a < b)
            {   
                int t = a;
                a = b;
                b = t;
            }
            int c = a % b;
            return c == 0 ? b : Gcd(b, c);
        }
        static void Main()
        {
            int[] i = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(Gcd(i[0], i[1]));
        }
    }
}

Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int grundy(int A, int K) {
    if (A < K) return 0;
    if (A % K == 0) return A / K;

    int dec = A / K + 1;
    A -= ((A % K - 1) / dec + 1) * dec;
    return grundy(A, K);
}

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

    int x = 0;
    for (int i = 0; i < N; ++i) {
        int A, K;
        cin >> A >> K;
        x ^= grundy(A, K);
    }
    cout << (x == 0 ? "Aoki" : "Takahashi") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[80][80];

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+1];
    int mm=0;
    int ind=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(mm<abs(a[i]))
        {
            mm=abs(a[i]);
            ind=i;
        }
    }
    vector<pair<int,int> >ans;
    for(int i=1;i<=n;i++)
    {
        if(i!=ind)
        {
            ans.push_back({ind,i});
                a[i]+=a[ind];
        }
    }
    if(a[ind]<0)
    {
        for(int i=n-1;i>=1;i--)
        {
            ans.push_back({i+1,i});
        }
    }
    else
    {
        for(int i=1;i<=n-1;i++)
        {
            ans.push_back({i,i+1});
        }
    }
    cout<<ans.size()<<"\n";
    for(auto i:ans)
        cout<<i.first<<" "<<i.second<<'\n';
} 


Measured memory_bytes: 256
from math import pi, sin, cos, tan
EPS = 0.0000000001

def f(a, b, theta):
    if theta > pi * 0.5 - EPS:
        ret = 0.0
    elif a * tan(theta) <= b:
        ret = a**2 * b - a**3 * tan(theta) * 0.5
    else:
        ret = a * b**2 * 0.5 / tan(theta)

    return ret

a, b, x = map(int, input().split())

ok = pi * 0.5
ng = 0.0
while ok - ng >= EPS:
    mid = (ok + ng) * 0.5
    if f(a, b, mid) < x:
        ok = mid
    else:
        ng = mid
print("{:.10f}".format(ok / pi * 180))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long k,n,m;
	cin>>n>>m>>k;
	vector<long long> v1(n+2,0);
	vector<long long> v2(m+2,0);
	for(int i=1;i<=n;i++){
	    cin>>v1[i];
	    v1[i]+=v1[i-1];
	}
	for(int i=1;i<=m;i++){
	    cin>>v2[i];
	    v2[i]+=v2[i-1];
	}
	int j=m,val=0;
	for(int i=0;i<=n;i++){
	    if(v1[i]>k) break;
	    while(v2[j]>(k-v1[i]))  j--;
	    val=max(val,(i+j));
	}
	cout<<val<<endl;
	return 0;
}

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

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

  set<string> a;
  map<string, map<int, int>> m;
  rep(i,0,N-1) {
    string s;
    int c;
    cin >> s >> c;
    a.insert(s);
    m[s].insert(map<int, int>::value_type(c, i+1));
  }

  for (string s:a) {
    vector<int> v;
    for (pair<int, int> p:m[s]) v.push_back(p.first);
    sort(v.begin(), v.end(), greater<int>());
    for (int n:v) cout << m[s][n] << endl;
  };

  return 0;
}


Measured memory_bytes: 256
from collections import deque
N=int(input())
G=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=map(int,input().split())
    u,v=u-1,v-1
    w%=2
    G[u].append([u,v,w])
    G[v].append([v,u,w])
color=[-1]*N
color[0]=0
stack=deque(G[0])
while(stack):
    u,v,w=stack.pop()
    if color[v]!=-1:
        continue
    if w==1:
        color[v]=1-color[u]
    else:
        color[v]=color[u]
    stack.extend(G[v])
[print(i) for i in color]


Measured memory_bytes: 88992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int MAXN = 2e5 + 10;

int N;
int A[MAXN];
bool B[MAXN];

bool check(int mid)
{
	const int Nmid = (N + 1) >> 1;
	int Lft = 0, Rht = N + 1;

	for (int i = 1; i <= N; i++)
		B[i] = (A[i] >= mid);

	for (int i = Nmid; i > 1; i--)
		if (B[i] == B[i - 1])
		{
			Lft = i;
			break;
		}
	for (int i = Nmid; i < N; i++)
		if (B[i] == B[i + 1])
		{
			Rht = i;
			break;
		}
	if(Lft == 0 && Rht == N + 1)
		return B[1];
	else if(Nmid - Lft > Rht - Nmid)
		return B[Rht];
	else
		return B[Lft];
}

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

	// [L, R)
	int L = 1, R = N + 1;
	while (L + 1 < R)
	{
		int mid = (L + R) >> 1;
		//cerr << L << " " << mid << " " << R << endl ;

		if (check(mid))
			L = mid;
		else
			R = mid;
	}

	cout << L << endl;

	return 0;
}


Measured memory_bytes: 1280
n=int(input())
dp=[0]*26
for i in range(n):
  S=input()
  for j in range(26):
    p=0
    for k in range(len(S)):
      if S[k]==chr(j+97):
        p+=1
    if i==0:
      dp[j]=p
      continue
    dp[j]=min(dp[j],p)
s=''
for i in range(26):
  for j in range(dp[i]):
    s+=chr(i+97)
print(s)

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

using namespace std;
typedef long long ll;

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

  int a, b;
  cin >> a >> b;

  if (a == 1) a = 14;
  if (b == 1) b = 14;

  if (a > b) cout << "Alice" << "\n";
  else if (a < b) cout << "Bob" << "\n";
  else cout << "Draw" << "\n";

}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    string a[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string S;
    cin >> S;
    int i = 0;
    while(a[i] != S) i++;
    cout << (7 - i) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
const int maxn=1005;
int n,m,k,dx[]={-1,1,0,0},dy[]={0,0,1,-1},vis[maxn][maxn];
char map[maxn][maxn];
struct maze
{
    maze(int xx=0,int yy=0,int tt=0):x(xx),y(yy),time(tt){}
	int x,y,time;
};
maze bfs(int bx,int by,char ch)
{
	memset(vis,0,sizeof(vis));
	queue<maze> q;
	maze st(bx,by,0);
	q.push(st);vis[bx][by]=1;
	while(!q.empty())
	{
		st=q.front();q.pop();
		if(map[st.x][st.y]==ch)
		{
			return st;
		}
		for(int i=0;i<4;++i)
		{
			int tx=st.x+dx[i],ty=st.y+dy[i];
			if(tx<0||tx>=n||ty<0||ty>=m||map[tx][ty]=='X')//越界和?
			{
				continue;
			}
			maze tp(tx,ty,st.time+1);
			if(!vis[tx][ty])
			{
				vis[tx][ty]=1;
				q.push(tp);
			}
		}
	}
}
int main()
{

	while(~scanf("%d%d%d",&n,&m,&k))
	{
		int bx,by;
		for(int i=0;i<n;++i)
		{
			scanf("%s",map[i]);
			for(int j=0;j<m;++j)
			{
				if(map[i][j]=='S')
				{
					bx=i;by=j;
					
					map[i][j]='0'; //第0个起点
				}
			}
		}
		int ans=0;
		for(int i=0;i<k;++i)
		{
			maze tp=bfs(bx,by,map[bx][by]+1);
			ans+=tp.time;
			bx=tp.x;by=tp.y;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 7596
#include <iostream>
#include <vector>
#include <cmath>

long long gcd(long long  a, long long b)
{
  return b? gcd(b, a%b): a;
}

std::vector<std::pair<long long, long long>>  factorizePrime(long long a)
{
  std::vector<std::pair<long long, long long>> prime_vec;
  for (long long i = 2; i*i <= a; ++i)
  {
    if(a%i!=0)
    {
      continue;
    }

    int num = 0;
    while(a%i == 0)
    {
      num++;
      a /= i;
    }
    prime_vec.push_back(std::make_pair(i, num));
  }
  if(a != 1){
    prime_vec.push_back(std::make_pair(a, 1));
  }
  return prime_vec;
}

void solve(long long  A, long long B)
{
  long long  a = gcd(A, B);
  // auto pf = prime_factorize(G);
  std::cout << factorizePrime(a).size()+1 << std::endl;
}

int main(void)
{
  long long A;
  long long B;
  std::cin >> A;
  std::cin >> B;
  solve(A,B);
  return 0;
}


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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};

signed main(){
  Int n;
  Int cnt=0;
  while(cin>>n,n){
    vector<string> ss(n);
    vector<Int> ls(n),vs(n);
    for(Int i=0;i<n;i++) cin>>ss[i]>>vs[i],ls[i]=ss[i].size();
    string t;
    cin>>t;
    Int m=t.size();

    const Int INF = 1e9;
    vector<Int> dp1(m+1,-INF);
    dp1[0]=0;

    for(Int i=0;i<m;i++){
      for(Int j=0;j<n;j++){
	if(i+ls[j]>m) continue;
	if(t.substr(i,ls[j])!=ss[j]) continue;
	chmax(dp1[i+ls[j]],dp1[i]+vs[j]);
      }
    }

    vector<Int> dp2(dp1[m]+1,INF);
    dp2[0]=0;
    for(Int i=0;i<dp1[m];i++){
      for(Int j=0;j<n;j++){
	if(i+vs[j]>dp1[m]) continue;
	chmin(dp2[i+vs[j]],dp2[i]+ls[j]);
      }      
    }
    
    cout<<"Case "<<++cnt<<": "<<dp2[dp1[m]]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3156
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [n,m,l] <- readInts
  a <- listArray ((1,1),(n,m)) . join <$> replicateM n readInts
  b <- listArray ((1,1),(m,l)) . join <$> replicateM m readInts
  let c = runSTArray $ do 
      ary <- newArray ((1,1),(n,l)) 0
      forM_ ((,) <$> [1..n] <*> [1..l]) $ \(i, j) -> do
        writeArray ary (i,j) $ sum [ a ! (i,k) * b ! (k,j) | k <- [1..m] ]
      return ary 
  forM_ [1..n] $ \i -> do
    forM_ [1..l] $ \j -> do
      printf "%d" $ c ! (i, j)
      if j == l then putChar '\n' else putChar ' '



Measured memory_bytes: 15412
"""
嘘解法です.通るかな?
コーナーケース:
in:
    abab
    aabb
Out:
    Yes
    (本当はNo)
"""
s = str(input())
t = str(input())
ls = [0]*26
lt = [0]*26
for i in range(len(s)):
    ls[ord(s[i])-97] += 1
    lt[ord(t[i])-97] += 1
ls.sort()
lt.sort()
if lt == ls:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	ll n,d;
	cin>>d>>n;
	if(d==0)
	{
		if(n!=100)
		cout<<n<<'\n';
		else
			cout<<n+1<<'\n';
	}
	else 
	{
		ll ans = 100;
		for(int i=0;i<d-1;i++)
		{
			ans*=100;
		}
		if(n!=100)
		cout<<n*ans<<'\n';
		else cout<<(n+1)*ans<<'\n';
	}
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		List<String> list = Arrays.asList("SUN","MON","TUE","WED","THU","FRI","SAT");
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		System.out.println(7-list.indexOf(in));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll fre[500005];
ll a[500005];
bool ispalindrome(string s){
    ll sz=s.size();
    for(ll i=0;i<sz;i++){
        if(s[i]!=s[sz-i-1]){
            return false;
        }
    }
    return true;
}
int main(){
    fastread;
    string s;
    ll n,i,j,k,lm;
    cin>>s;
    n=s.size();
    if(!(ispalindrome(s))){
        cout<<"No";
        return 0;
    }
    string s1=s.substr(0,(n-1)/2);
    if(!(ispalindrome(s1))){
        cout<<"No";
        return 0;
    }
    string s2=s.substr((n+3)/2-1,n-(n+3)/2+1);
    if(!(ispalindrome(s2))){
        cout<<"No";
        return 0;
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define md 1000000000000000000
int main()
{
  long long int n;
  cin>>n;
  string a;
  cin>>a;
  long long int num=0;
  for(int i=0;i<a.length();i++)
   {
    if(a.at(i)=='.') continue;
     num=num*10+(int)a.at(i)-48;
   }
  long long int pr=num*n;
  pr/=100;
  cout<<pr<<endl;
   return 0;
}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h,w=list(map(int,input().split()))
    while (h,w)!=(0,0):
        row = "#" * w
        for _ in range(h):
            print(row)
        print()
        h,w=list(map(int,input().split()))

main()



Measured memory_bytes: 5624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
	string s,t;
    int n,a,b,c,d,e;
    cin >> a >> b >> d;
	int ans = 0;
 	loop(i,a,b+1)if(i%d == 0)ans++;
	cout << ans << endl;
}


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

int N;
string A,B,C;

int main(){
  cin>>N>>A>>B>>C;
  int ans=0;
  for(int i=0;i<N;i++){
    map<char,int> mp;

    int maxm=0;
    
    mp[ A[i] ]++;
    maxm=max(maxm,mp[ A[i] ]);
    mp[ B[i] ]++;
    maxm=max(maxm,mp[ B[i] ]);
    mp[ C[i] ]++;
    maxm=max(maxm,mp[ C[i] ]);
    if(maxm==1){
      ans+=2;
    }else if(maxm==2){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
fib' :: Int -> Int
fib' n = fibi n 1 0
  where
    fibi 0 a1 _ = a1
    fibi n a1 a2 = fibi (n-1) (a1+a2) a1

main :: IO()
main = do
    x <- readLn :: IO Int
    print $ fib' x 

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

int main() {
  int N;//参加回数
  int R;//表示レーティング
  int inerR;//内部レーティング
  
  cin>>N>>R;
  if(N>=10){
    inerR = R;
  }else{
    inerR = R+(100 *(10-N));
  }
  cout<<inerR<<endl;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
  //  #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  //  #endif
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=(n/(a+b))*a;
    ans+=min(a,n%(a+b));
    cout<<ans;
    return 0;
}



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

int main(){
  int N, tmp;
  cin >> N;
  string result = "APPROVED";

  for(int i=0;i<N;i++){
    cin >> tmp;
    if(tmp%2==0){
      if(tmp%3!=0 && tmp%5!=0){
        result = "DENIED";
        break;
      }
    }
  }
  cout << result << endl;

}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    ll A;
    double B;
    cin >> A >> B;
    ll B2 = round(B * 100);
    cout << A * B2 / 100 << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3800
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int N = Integer.valueOf(sc2.nextLine()); 
			if (N == 0) {
				return;
			}
			String[][] info = new String[N][];
			for (int i = 0; i < N; i++) {
				info[i] = sc2.nextLine().split(" ");
			}
			Result[] res = new Result[N];
			for (int i = 0; i < N; i++) {
				int score = 0;
				int turn = 0;
				for (int j = 1; j < info[i].length; j++) {
					int pin = Integer.valueOf(info[i][j]);
					turn++;
					int add = 0;
					if (turn > 10) {
						break;
					}
					if (turn == 10) {
						for (int k = j; k < info[i].length; k++) {
							add += Integer.valueOf(info[i][k]);
						}

					} else if (j + 2 < info[i].length && pin == 10) {
						add += 10;
						add += Integer.valueOf(info[i][j + 1]);
						add += Integer.valueOf(info[i][j + 2]);
					} else if (pin + Integer.valueOf(info[i][j + 1]) == 10) {
						add += 10;
						add += Integer.valueOf(info[i][j + 2]);
						j++;
					} else {
						add += pin + Integer.valueOf(info[i][j + 1]);
						j++;
					}
					score += add;
				}
				res[i] = new Result(Integer.valueOf(info[i][0]), score);
			}
			Arrays.sort(res, new ComparatorResult());
			for (Result out : res) {
				System.out.println(out.id + " " + out.score);
			}
		}
	}

	class Result {
		int id;
		int score;

		public Result(int id, int score) {
			super();
			this.id = id;
			this.score = score;
		}
	}

	class ComparatorResult implements Comparator<Result> {
		@Override
		public int compare(Result arg0, Result arg1) {
			int cmp = -1;
			if (arg0.score < arg1.score) {
				cmp = 1;
			} else if (arg0.score == arg1.score) {
				if (arg0.id > arg1.id) {
					cmp = 1;
				} else {
					cmp = -1;
				}
			}
			return cmp;
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 23800
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int l = Integer.parseInt(str[1]);
    String[] s = new String[n];

    for(int i=0; i<n; i++) {
      s[i] = in.readLine();
    }
    
    Arrays.sort(s);
    
    for(int i=0; i<n; i++) {
      System.out.print(s[i]);
    }
    
    System.out.println();
  }
}

Measured memory_bytes: 32732
<?php
  
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%s", $s);
$num = strlen($s);
if($num <= $k){
  	echo $s;
  }else{
  	$str = substr($s, 0, $k);
    echo $str;
    echo "...";
  }

Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	s64 N, K;
	cin >> N >> K;
	
	if(N == K) {
		cout << 0;
		return 0;
	} else if(N > K) {
		u64 fdiff = N - K;
		if(fdiff < K) {
			N = N - K;
		} else {
			N = N - K * (fdiff / K);
		}
	}
	
	for(u64 t=0; t<3; t++) {
		N = min(abs(N - K), N);
	}
	
	cout << N;
	
	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#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

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int r, c, v, s[101] = {};
	cin >> r >> c;
	for (int i = 0, t; i < r; ++i) {
		t = 0;
		for (int j = 0; j < c; ++j) {
			cin >> v;
			cout << v << " ";
			s[j] += v;
			t += v;
		}
		s[c] += t;
		cout << t << endl;
	}
	for (int i = 0; i < c; ++i) {
		cout << s[i] << " ";
	}
	cout << s[c] << endl;

	return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        string S;
        cin >> S;
        cout << S << endl;
        cout << S << endl;
    }
}



Measured memory_bytes: 256