akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <stack>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <set>
#include <map>
#include <utility>
#include <iomanip>
#include <ctime>
#include <sstream>
#include <bitset>
#include <deque>
#include <limits>
#include <numeric>
#include <functional>

#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define sort(a,n,int) sort(a,a+n,less<int>())
#define fread() freopen("in.in","r",stdin)
#define fwrite() freopen("out.out","w",stdout)
using namespace std;

typedef long long ll;
typedef char ch;
typedef double db;  

const int maxn=1e5+10;
//ll a[maxn];
int aa[maxn];

int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else gcd(b,a%b);
}

int main(){
	int n ;
	cin>>n;
	cout<<n*n*3;
	
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
if n % 2 == 0:
    b = [2 if i % 2 == 1 else 0 for i in range(n)]
else:
    b = [2 if i % 2 == 0 else 0 for i in range(n)]
    b[0] = 1
c = [0 for i in range(n)]
for i in range(n):
    c[a[i]] += 1
if b != c:
    print(0)
else:
    ans = 1
    for i in range(n // 2):
        ans *= 2
        ans %= mod
    print(ans)

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

int main(){
    int n, i, total = 0;
    cin >> n;
    int a[n+2] = {};
    for(i=1; i<=n; i++){
        cin >> a[i];
        total += abs(a[i]-a[i-1]);
    }
    total += abs(a[n]);
    for(i=1; i<=n; i++){
        cout << total + abs(a[i+1]-a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<algorithm>
int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	long long int ans=1000000000000000000;
	for(int i=0;i<=(std::max(x,y))*2;i++){
		int aa=std::max(0,x-i/2);
		int bb=std::max(0,y-i/2);
		long long int p=aa*a+bb*b+i*c;
		if(p<ans)ans=p;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  string S ;
  int len, block = 0, ans = 1, check;
  cin >> S ;
  len = S.size() ;
  block = (len + 1) / 2 ;
  for(int i=0;i<(len/2);i++){
    if(S.at(i) != S.at(len-1-i)){
      ans = 0 ;
      break ;
    }
  }
  for(int i=0;i<(len/2);i++){
    if(S.at(i) != S.at(i+block)){
      ans = 0 ;
      break ;
    }
  }
  if(ans){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}  

Measured memory_bytes: 256
from collections import deque

s = input()
Q = int(input())

dq = deque(list(s))

reversed_state = False
  
for q in range(Q):
  query = input().split()
  if len(query) == 1:
    reversed_state = not reversed_state
  else:
    T,F,c = list(query)
    if F == '1':
      if reversed_state == False:
      	dq.appendleft(c)
      else:
        dq.append(c)
    else:
      if reversed_state == False:
        dq.append(c)
      else:
        dq.appendleft(c)
      
print(''.join(dq)) if reversed_state == False else print(''.join(list(dq)[::-1]))

Measured memory_bytes: 10084
#include <cstdio>
#include <cmath>
struct point{
	double x, y;
	point(double _x = 0, double _y = 0){
		x = _x, y = _y;
	}
	point operator + (const point &rhs) const { return point(x + rhs.x, y + rhs.y); }
	point operator - (const point &rhs) const { return point(x - rhs.x, y - rhs.y); }
}A, B, C, D;
int q;
double dot_product(point a, point b){
	return a.x * b.x + a.y * b.y;
}
point projection(point p, point a, point b){
	double l1 = dot_product(p - a, b - a);
	double l2 = dot_product(b - a, b - a);
	double d = l1 / l2;
	return point(a.x + (b.x - a.x) * d, a.y + (b.y - a.y) * d);
}
point reflection(point p, point a, point b){
	point t = projection(p, a, b);
	return point(2 * t.x - p.x, 2 * t.y - p.y);
}
int main(){
	scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);
	scanf("%d", &q);
	for (register int i = 1; i <= q; ++i){
		scanf("%lf%lf", &C.x, &C.y);
		D = reflection(C, A, B);
		printf("%.10lf %.10lf\n", D.x, D.y);
	}
}


Measured memory_bytes: 2764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  ull n;
  cin >> n;

  vector<ull> p = {};
  each(i, n) {
    ull tmp;
    cin >> tmp;
    p.push(tmp);
  }

  ull maxx = p[0];
  ull minn = p[0];
  ull res = 0;
  each(i, n) {

    minn = min(p[i], minn);

    if (p[i] <= minn) {
      res++;
    }


    /*
    if (minn < p[i] && p[i] < maxx) {
      cout << "max: " << maxx << " minn: " << minn << endl;
      res++;
      maxx = min(p[i], maxx);
      minn = max(p[i], minn);
cout << "max: " << maxx << " minn: " << minn << endl;
    } else if (maxx < p[i]) {
      maxx = p[i];
    } else if (p[i] < minn) {
      minn = p[i];
    }
    */

  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3444
/***** author : C0d1ngPhenomena *****/

	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		cin.tie(NULL);
		ll N, n, sum=0;

		cin>> N >>n;
		ll a;

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

		ll ans = N - sum;

		if(ans<0)
			cout<< -1;
		else
			cout<<ans;
		

		return 0;
	}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a > k) {
        a -= k;
    } else if (a + b > k) {
        b -= (k - a);
        a = 0;
    } else {
        a = 0;
        b = 0;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
public class UnionFind {
    private int[] par, rank; //親、木の深さ

    public UnionFind(int size) { //初期化
        par = new int[size];
        rank = new int[size];
        for (int i = 0; i < size; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    public void Unite(int x, int y) { //xが属しているグループとyが属しているグループを統合する
        //親が同じなら何もしない
        x = Find(x);
        y = Find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        }
        else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }    
    }

    public bool IsSameGroup(int x, int y) { //xとyが同じグループに属しているかどうか
        return Find(x) == Find(y);
    }

    public int Find(int x) { //ノードxの根を求める
        if(par[x] == x) {
            return x;
        }
        else {
            return par[x] = Find(par[x]);
        }
    }

    public int Size(int x) => -par[Find(x)];
}

class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        int M = cin.Int();
        var p = cin.ArrayInt(N);

        var uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            int x = cin.Int() - 1;
            int y = cin.Int() - 1;
            if(!uf.IsSameGroup(x, y)) {
                uf.Unite(x, y);
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if(uf.IsSameGroup(p[i] - 1, i)) {
                ans++;
            }
        }

        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long llong;
llong mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
 int n;
 cin>>n;
vector<llong> a(n);
for(llong i=0;i<n;i++)cin>>a.at(i);
llong ans=0;
for(int i=0;i<60;i++){
  llong x0=0;
  llong x1=0;
  for(llong k=0;k<n;k++){
    llong x=(a.at(k)>>i)&1;
    x==0?x0++:x1++;
  }
  llong cnt=x0*x1%mod;
  for(llong j=0;j<i;j++)cnt=cnt*2%mod;
  ans+=cnt;
  }
cout<<ans%mod<<endl;
return 0;
}


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

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    for(auto &it : v) cin >> it;

    int64_t ans = 0;
    for (int i = 0; i+1 < n; i++) {
        if (v[i+1] < v[i]) {
            ans += abs(v[i+1] - v[i]);
            v[i+1] = v[i];
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3988
A,B,K=map(x->parse(Int,x),split(readline()))
T=Array{Int}(0)
for i=1:K
  push!(T,A+i-1)
  push!(T,B-i+1)
end
sort!(T)
T=unique(T)
for t=T
  if A<=t<=B
    println(t)
  end
end

Measured memory_bytes: 111900
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
map<int,int>mp;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    REP(i,n)cin>>a[i];
    vector<int>d(1000100,0);
    SORT(a);



    REP(i,n){
        for(int j=1;a[i]*j <= 1000100;j++){
            d[a[i]*j]++;
            if(d[a[i]]!=1)break;
        }   
    }
    ll answer = 0;
    REP(i,n){
        if(d[a[i]]==1)answer++;
    }
    cout << answer <<endl;
    return 0;
}

Measured memory_bytes: 8804
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll n;
ll ksm(ll a,ll b){
    ll ans=1;
    while(b){
            if(b&1){
                 ans*=a;
            ans%=mod;
            }

            a*=a;
            a%=mod;
            b>>=1;
    }
return ans;
}
int main()
{
    cin>>n;
    cout<<(ksm(10,n)%mod-2*ksm(9,n)%mod+ksm(8,n)%mod+mod)%mod<<endl;
    return 0;
}
////刷题！！！！！！！！！！！！！！！！


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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;
int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   string a, b; cin >> a >> b;
   string ans = "";
   reverse(all(a));
   reverse(all(b));
   int n = a.size() + b.size();
   for(int i = 1; i <= n ; i++)
   {
      if(i%2)
      {
         ans += a.back();
         a.pop_back();
      }
      else
      {
         ans += b.back();
         b.pop_back();
      }
   }
   cout << ans << nl;

}


Measured memory_bytes: 3616
h,w = map(int,input().split())
l=[]
for i in range(h):
  s = list(input())
  l.append(s)
for i in range(h):
  for j in range(w):
    kazu = 0
    if l[i][j] == '.':
      if j != 0 and l[i][j-1] == '#':
        kazu += 1
      if j != w-1 and l[i][j+1] == '#':
        kazu += 1
      if i != 0 and l[i-1][j]== '#':
        kazu += 1
      if i != h-1 and l[i+1][j] == '#':
        kazu += 1
      if i >= 1 and j >= 1 and l[i-1][j-1] == '#':
        kazu += 1
      if i >= 1 and j <= w-2 and l[i-1][j+1] == '#':
        kazu += 1
      if i <= h-2 and j >= 1 and l[i+1][j-1] == '#':
        kazu += 1
      if i <= h-2 and j <= w-2 and l[i+1][j+1] == '#':
        kazu += 1
      l[i][j] = str(kazu)
for i in range(h):
  print(''.join(l[i]))

Measured memory_bytes: 39920
n = gets.to_i
h = Hash.new(0)
h[0] = 0
xy = []

n.times do
    x, y = gets.split.map(&:to_i)

    xy.each do |(xi, yi)|
        a = x - xi
        b = y - yi
        h[[a, b]] += 1
        h[[-a, -b]] += 1
    end

    xy << [x, y]
end

puts n - h.values.max

Measured memory_bytes: 1916
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,P;
    cin >> N >> M >> P;
    ll A[5010], B[5010], C[5010];
    vector<lpair> tree[2510];
    rep(i,0,M){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        C[i] -= P;
        C[i] *= -1;
        tree[A[i]].push_back(make_pair(B[i], C[i]));
        tree[B[i]].push_back(make_pair(A[i], C[i]));
    }
    ll dist[2510] = {};
    rep(i,1,N) dist[i] = INF;
    rep(loop, 0, N-1){
        rep(i,0,M){
            if(dist[A[i]] == INF) continue;
            if(dist[B[i]] > dist[A[i]] + C[i]){
                dist[B[i]] = dist[A[i]] + C[i];
            }
        }
    }
    ll ans = dist[N-1];

    bool negative[2510];
    rep(i,0,N) negative[i] = false;
    rep(loop,0,N){
        rep(i,0,M){
            if(dist[A[i]] == INF) continue;
            if(dist[B[i]] > dist[A[i]] + C[i]){
                dist[B[i]] = dist[A[i]] + C[i];
                negative[B[i]] = true;
            }

            if(negative[A[i]] == true) negative[B[i]] = true;
        }
    }
    if(negative[N-1]){
        print(-1);
    }else{
        if(dist[N-1] > 0){
            print(0);
        }else{
            print(dist[N-1] * -1);
        }
    }


}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int cnt;
    char n[5];
    cin>>n;
    bool f = false;
    for(int i = 0; i < 4; i++)
    {
        cnt = 1;
        for(int j = i+1; j < 4; j++)
        {
            if(n[i] == n[j])
                cnt++;
            else
                cnt = 0;
            if(cnt>2)
            {
                f = true;
            }
        }
    }
    if(f)
        puts("Yes");
    else
        puts("No");
    return 0;
}


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

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

  float sum;
  for(int i = 0; i < n; i++) {
    int A_i;
    cin >> A_i;
    sum += 1.0 / A_i;
  }

  cout << 1.0 / sum << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int M;
  cin >> M;
  vector<vector<int>> data(M, vector<int>(2));
  for(int j=0; j<M; j++){
    for(int k=0; k<2; k++){
      cin >> data.at(j).at(k);
    }
  }
  
  for(int l=0; l<M; l++){
    int x = 0;
    int ans = 0;
    int minus = 0;
    x = data.at(l).at(0);
    minus = vec.at(x - 1) - (data.at(l).at(1));
    for(int m=0; m<N; m++){
      ans = ans + vec.at(m);
    }
     cout << ans - minus << endl; 
  }
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> L, std::vector<long long> R){
  vector<pll> v(N);
  REP(N){
    v[i]=pll(L[i],R[i]);
  }
  sort(v.begin(),v.end(),[](pll a,pll b){return (a.second-a.first)<(b.second-b.first);});
  dump(v);
  set<pll> s;
  REP(N){
    auto itr = s.lower_bound(pll(v[i].first,0));
    if(itr==s.end()||itr->second>v[i].second){
      s.insert(v[i]);
    }
  }
  vector<pll> vv(s.begin(),s.end());
  ll ans=0;
  REP(vv.size()-1){
    ll l,r;
    l=max(0LL,vv[0].second-vv[i].first+1);
    r=max(0LL,vv[i+1].second-vv[vv.size()-1].first+1);
    ans=max(ans,l+r);
  }
  dump(vv);
  ll l=max(0LL,vv[0].second-vv[vv.size()-1].first+1);
  ll r=v.back().second-v.back().first+1;
  ans=max(ans,r+l);
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    std::vector<long long> R(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
    }
    solve(N, std::move(L), std::move(R));
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

#define MAX_H 20
#define MAX_W 20
#define MAX_T 150

struct Data{
    int n,c,s,t;
    Data(){}
    Data(int n,int c,int s,int t) :
        n(n),c(c),s(s),t(t) {}

    bool operator < (const Data &d)const{
        return n < d.n;
    }
};

int H,W,LIMIT;
int memo[MAX_H][MAX_W][MAX_T][1<<8];
vector<Data> v;
char field[MAX_H][MAX_W];
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

bool inField(int x,int y){
    return (0 <= x && x < W && 0 <= y && y < H);
}

bool check(int nt,int idx){
    return (v[idx].s <= nt && nt < v[idx].t);
}

int solve(int x,int y,int t,int p){
    if(t == LIMIT) return 0;
    int &res = memo[x][y][t][p];
    if(res != -1) return res;
    int S = p,cost = 0;
    for(int i = 0 ; i < 4 ; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(!inField(nx,ny)) continue;
        if(field[ny][nx] == '.') continue;
        int x = field[ny][nx]-'0';
        if(S >> x & 1) continue;
        if(check(t,x)){
            S |= (1<<x);
            cost += v[x].c;
        }
    }
    for(int i = 0 ; i < 4 ; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(!inField(nx,ny)) continue;
        if(field[ny][nx] != '.') continue;
        res = max(res,solve(nx,ny,t+1,S)+cost);
    }
    return res;
}

int main(){
    int sx,sy,N;
    while(cin >> W >> H, W){
        for(int i = 0 ; i < H ; i++){
            for(int j = 0 ; j < W ; j++){
                cin >> field[i][j];
                if(field[i][j] == 'P'){
                    sx = j; sy = i;
                    field[i][j] = '.';
                }
            }
        }
        LIMIT = 0;
        cin >> N;
        v.clear(); v.resize(N);
        for(int i = 0 ; i < N ; i++){
            cin >> v[i].n >> v[i].c >> v[i].s >> v[i].t;
            LIMIT = max(LIMIT,v[i].t);
        }
        LIMIT++;
        memset(memo,-1,sizeof(memo));
        cout << solve(sx,sy,0,0) << endl;
    }
    return 0;
}

Measured memory_bytes: 61220
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        int N = int.Parse(inputs[0]);
        int M = int.Parse(inputs[1]);
        var AB = new Pair[N]; ;
        for (int i = 0; i < N; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            AB[i] = new Pair(long.Parse(inputs[0]), long.Parse(inputs[1]));
        }

        var sorted = AB.OrderBy((ab) => ab.A).ToArray();
        long sum = 0;
        long count = 0;
        for (int i = 0; i < N; i++)
        {
            var pair = sorted[i];
            if (count + pair.B > M)
            {
                sum += pair.A * (M - count);
                count = M;
            }
            else
            {
                sum += pair.A * pair.B;
                count += pair.B;
            }

            if (count == M)
            {
                break;
            }
        }

        Console.WriteLine(sum);

    }

    private struct Pair
    {
        internal long A;
        internal long B;
        internal Pair(long A, long B)
        {
            this.A = A;
            this.B = B;
        }
    }

}



Measured memory_bytes: 24776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N,M;
    cin >> N >> M;
    map<int,int> m;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        m[a]++;
        m[b]++;
    }
    bool ans=true;
    for (auto x:m){
        int c=x.second;
        if (c%2==1){
            ans=false;
        }
    }
    if (ans){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
 
int main(void){
	
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	a = b * 10 + c; 
	
	if(a%4==0){
	printf("YES\n");
	} else {
	printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 100;
int main() {
    int n, l;
    string s[MAX];

    cin >> n >> l;
    for (int i = 0; i < n; ++i) cin >> s[i];

    sort(s, s + n);
    for (int i = 0; i < n; ++i) cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    //#define ll long long
    using namespace std;
    #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
    #define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
    #define ll long long
    #define pb push_back
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define mp make_pair
    #define N 2000001
    #define M 998244353
    #define INF 1000000000000000
  ll gcd(ll a,ll b)
  {
    if(b==0)return a;
    else return(gcd(b,a%b));
  }

int main()
{
  SPEED;
ll i,x,n;
cin>>x>>n;
unordered_map<ll,ll> m;
ll a[n];
for(i=0;i<n;i++)
{
  cin>>a[i];m[a[i]]=1;
}
for(i=0;;i++)
{
  if(m[x-i]==0)
  {
    cout<<x-i;return 0;
  }
  if(m[x+i]==0)
  {
    cout<<x+i;return 0;
  }
 
}


}


Measured memory_bytes: 3656
using System;
public class ID {
    public static void Main() {
        string read = Console.ReadLine();
        int N = int.Parse(read);
        string S = Console.ReadLine();
        string test;
        int x = 0;
        int max = 0;
        for (int i = 0; i < N; i++) {
            test = S.Substring(i, 1);
            if (test == "I") {
                x++;
                if (x > max) {
                    max = x;
                }
            } else {
                x--;
            }
        }
        Console.WriteLine(max);

    }
}

Measured memory_bytes: 2776
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Circle {
  int x;
  int y;
  int r;

  Circle(int x = -1, int y = -1, int r = -1) {
    this->x = x;
    this->y = y;
    this->r = r;
  }
};

struct Node {
  int v;
  double dist;

  Node(int v = -1, double dist = -1) {
    this->v = v;
    this->dist = dist;
  }

  bool operator>(const Node &n) const {
    return dist > n.dist;
  }
};

int main() {
  int XS, YS, XT, YT;
  int N;

  cin >> XS >> YS >> XT >> YT;
  cin >> N;

  vector<Circle> circles;
  circles.push_back(Circle(XS, YS, 0));

  int x, y, r;

  for (int i = 0; i < N; ++i) {
    cin >> x >> y >> r;
    circles.push_back(Circle(x, y, r));
  }

  circles.push_back(Circle(XT, YT, 0));

  priority_queue <Node, vector<Node>, greater<Node> > pque;
  pque.push(Node(0, 0.0));

  bool visited[N + 2];
  memset(visited, false, sizeof(visited));

  while (!pque.empty()) {
    Node node = pque.top();
    Circle from = circles[node.v];
    pque.pop();

    if (visited[node.v]) continue;
    visited[node.v] = true;

    if (node.v == N + 1) {
      cout << setprecision(10) << node.dist << endl;
      break;
    }

    for (int u = 1; u <= N + 1; ++u) {
      if (visited[u]) continue;

      Circle to = circles[u];
      double dist = sqrt(pow(from.y - to.y, 2) + pow(from.x - to.x, 2));
      dist = max(0.0, dist - from.r - to.r);

      pque.push(Node(u, node.dist + dist));
    }
  }

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int s, w;
  cin >> s >> w;
  string ans = s > w ? "safe" : "unsafe";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int a, b, k;
  scanf("%d %d %d", &a, &b, &k);

  int ans, times = k;
  for (int i = min(a, b); i > 0; i--)
  {
    if (a % i == 0 && b % i == 0)
    {
      ans = i;
      times--;
    }
    if (times == 0)
      break;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
s = input()

r = s.count("R")
b = s.count("B")
if r > b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 7752
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<utility>
#include<string>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<cmath>
#include<time.h>
using namespace std;

int n;
long long arr[400000];
long long brr[400000];
int ans;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lld",arr+i);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",brr+i);
	}
	for(int i=0;i<30;i++){
		int mod=(1<<(i+1))-1;
		vector<int> a;
		vector<int> b;
		//각 수를 mod로 나눈 나머지
		for(int j=0;j<n;j++){
			a.push_back(arr[j] & mod);
		}
		for(int j=0;j<n;j++){
			b.push_back(brr[j] & mod);
		}
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		long long ret=0;
		for(int j=0;j<n;j++){
			//a[j] + b[k] 가 (1<<i)이상 (1<<(i+1)) 미만
			//a[j] + b[k] 가 3*(1<<i) 이상 (1<<(i+2))미만의 수의 합을 구하자
			int x=lower_bound(b.begin(),b.end(),(1<<(i+1))-a[j])-lower_bound(b.begin(),b.end(),(1<<i)-a[j]);
			int y=lower_bound(b.begin(),b.end(),(1<<(i+2))-a[j])-lower_bound(b.begin(),b.end(),3*(1<<i)-a[j]);
			ret+=(x+y);
		}
		if(ret%2==1) ans+=(1<<i);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8556
distance = input()
lis = distance.split()
judge = 0

spelis = sorted([int(lis[0]),int(lis[2])])

if int(spelis[1]) - int(spelis[0]) <= int(lis[-1]):
    print("Yes")

else:
    lis = sorted(lis)
    for times in range(len(lis)-1):
        difference = int(lis[times+1]) - int(lis[times])
        if difference <= int(lis[-1]):
            judge += 1

    if judge == len(lis)-1:
        print("Yes")

    else:
        print("No")

Measured memory_bytes: 3064
/*

*/
#include <bits/stdc++.h>

using namespace std;

#define ll           long long int
#define vi 			 vector<int>
#define pb           push_back
#define fi           first
#define si           second
#define pii 		 pair<int,int>
#define vii 		 vector<pair<int,int>>
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define mem(a,b)     memset(a, b, sizeof a)
#define matrix(x) 	 vector<vector<x>>
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;
ll dp[2002];

ll func(ll s){
	//base case
	if(s == 0){return 1;}
	if(s < 3){return 0;}
	//recurisve case
	if(dp[s]!=-1){return dp[s];}
	ll ans=0;
	for(ll i=3; i<=s; i++){
		ans += func(s-i)%mod;
	}
	return dp[s] = ans;
}

int main(){
	fastIO
	ll s;
	mem(dp, -1);
	cin>>s;
	cout<<func(s)%mod;
}

Measured memory_bytes: 3680
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
ll read()
{
	ll s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
ll n,a,b;
ll f(ll x,ll y){return abs(x-y)>>1;}
int main()
{
	n=read(),a=read(),b=read();
	if(!((b-a)&1))
	{
		printf("%lld\n",abs(b-a)>>1);
	}
	else
	{
		ll mn=min(a,b),mx=max(a,b);
		ll wei1=mn-1; ll ans1=f(mx-wei1-1,mn-wei1)+wei1+1;
		ll wei2=n-mx; ll ans2=f(mx+wei2,mn+wei2+1)+wei2+1;
		ll ans=min(ans1,min(ans2,min(n-mn,mx-1)));
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val S = sc.next

    val a = ArrayBuffer.fill(N)(0)
    ('a' to 'z').foreach { c =>
      val cc = S.zipWithIndex.filter(_._1 == c).map(_._2)
      if (cc.length >= 2) {
        (cc.head to cc.last).foreach { i => a(i) += 1 }
      }
//      println(a)
    }
    a.max.toString
  }
}


Measured memory_bytes: 29372
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
void cxxio() {
    ios::sync_with_stdio(false);
    cin.tie(0);
}
#define all(x) (x).begin(), (x).end()

int main() {
    cxxio();
    int n;
    cin>>n;
    vi run(n+1);
    for (int x; cin>>x;)
        run[x]=1+run[x-1];
    int best=*max_element(all(run));
    cout<<(n-best)<<'\n';
}


Measured memory_bytes: 1024
vec = []

loop do
  h, w = gets.split.map(&:to_i)
  break if h.zero? && w.zero?

  vec << [h, w]
end

vec.each do |v|
  h = v[0]
  w = v[1]
  edge = '#' * w

  puts edge

  (h - 2).times do
    puts '#' + '.' * (w - 2) + '#'
  end

  puts edge
  puts ''
end



Measured memory_bytes: 6952
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int read() {
    static char s[1 << 16];
    static int i, n;
    int r = 0;
    for (;;) {
        if (i == n) {
            cin.read(s, sizeof(s));
            i = 0;
            n = (int)cin.gcount();
            if (n == 0) break;
        }
        unsigned int c = s[i++] - '0';
        if (c < 10) {
            r *= 10;
            r += c;
        } else {
            break;
        }
    }
    return r;
}

int main() {
    int n = read();

    vector<int> m;
    m.reserve(n);

    for (int i = 0; i < n; i++) {
        int a = read();

        auto it = upper_bound(m.begin(), m.end(), a, greater<>());
        if (it == m.end()) m.push_back(a); else *it = a;
    }

    cout << m.size() << endl;

    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}
int char_to_int(char val) {
    return val - '0';
}

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

    cout << std::fixed << std::setprecision(15) << 2 * R * 3.1415926535 << endl;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
int main(){
    ll n,x;
    cin >> n >> x;
    vector<ll> v(n);
    ll a;
    cin >> v[0];
    v[0] = abs(v[0]-x);
    a = v[0];
    for(ll i=1;i<n;i++){
        std::cin >> v[i];
        v[i] = abs(v[i] - x);
        a = gcd(a,v[i]);
    }
    cout << a << endl;
}

Measured memory_bytes: 1024
import sys
#input = sys.stdin.buffer.readline
from collections import Counter

def main():
    N,P = map(int,input().split())
    S = input()
    
    if 10%P == 0:
        ans = 0
        for i,st in enumerate(S[::-1]):
            num = int(st)
            if num % P == 0:
                ans += N-i
    else:
        ans,base = 0,1
        MOD_list = [0]
        for st in S[::-1]:
            num = int(st)
            MOD = (MOD_list[-1]+num*base)%P
            MOD_list.append(MOD)
            base *= 10
            base %= P
        c = Counter(MOD_list)
        for v in c.values():
            ans += (v*(v-1))//2
        
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 49340
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,n) for(int i=0;i<n;i++)
#define For1(i,n) for(int i=1;i<=n;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
//#define int long long
/*/-----------------------------Code begins----------------------------------/*/
int main(){
int n;
cin>>n;
vi v(n);
For(i,n)
cin>>v[i];
vi cost(n,inf);
cost[0]=0;
for(int i=0;i<=n-2;i++){
    cost[i+1]=min(cost[i]+abs(v[i+1]-v[i]),cost[i+1]);
    if(i<n-2)
        cost[i+2]=min(cost[i]+abs(v[i+2]-v[i]),cost[i+2]);
}
cout<<cost[n-1];
}

















Measured memory_bytes: 1024
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment (linker, "/stack:256000000")

#include <iostream>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <cmath>
#include <cassert>
#include <ctime>
#include <memory.h>

using namespace std;

#define fo(a,b,c) for(int a=(b);a<(c);a++)
#define fd(a,b,c) for(int a=(b);a>=(c);a--)
#define fi(a) fo(i,0,(a))
#define fj(a) fo(j,0,(a))
#define fk(a) fo(k,0,(a))
#define _(a,b) memset((a),(b),sizeof(a))
#define __(a) memset((a),0,sizeof(a))
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__);fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << (x) << endl;}
#else
#define dbg(...) {}
#define dbgx(x) {}
#endif

typedef long long lint;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int INF = 1000000000;
const lint LINF = 4000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

lint n, a, b;

void read()
{
	cin >> n >> a >> b;
}

bool solve()
{
	lint r1 = a * (n - 1) + b;
	lint r2 = b * (n - 1) + a;
	cout << max(0LL, r2 - r1 + 1) << endl;
	return false;
}

int main()
{
	prepare();
	read();
	while (solve());
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
arr = [list(map(str, input().rstrip())) for _ in range(h)]
MOD = 10**9 + 7

# dpテーブル
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[1][1] = 1

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if arr[i - 1][j - 1] == "#":
            continue
        else:
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1]

print(dp[h][w] % MOD)

Measured memory_bytes: 164852
/*  ex5_3
    potter0723sw  */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height, width, i, j, rowblack[100]={0}, colblack[100]={0};
    char cell[100][100];
    scanf("%d %d", &height, &width);

    for(i=0; i < height; i++){//マスの入力を受け取る
        for(j=0; j < width; j++){
            scanf(" %c", &cell[i][j]);
        }
    }

    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if(cell[i][j] == '#'){
                rowblack[i] = 1;
            }
        }
    }

    for(j=0; j < width; j++){
        for(i=0; i < height; i++){
            if(cell[i][j] == '#'){
                colblack[j] = 1;
            }
        }
    }

    for(i=0; i < height; i++){
        if(rowblack[i]==1){
            for(j=0; j < width; j++){
                if(colblack[j] == 1){
                    printf("%c", cell[i][j]);
                }
            }
        }
    printf("\n");
    }
}


Measured memory_bytes: 128
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int n, m, x[MaxN], y[MaxN];

int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++) scanf("%d", x+i);
    for(int i=1;i<=m;i++) scanf("%d", y+i);
    LL sx = 0;
    LL sy = 0;
	for(int i = 1; i <= n; i++) {
		sx = (sx+(LL)x[i]*(i-1)%mod)%mod;
		sx = (sx-(LL)x[i]*(n-i)%mod+mod)%mod;
	}
    for(int i = 1; i <= m; i++) {
		sy = (sy+(LL)y[i]*(i-1)%mod)%mod;
		sy = (sy-(LL)y[i]*(m-i)%mod+mod)%mod;
	}
	printf("%lld\n", sx*sy%mod);
    //system("pause");
}


Measured memory_bytes: 1024
from math import sqrt

while True:
    n = int(input())
    if n==0:break
    s = list(map(int,input().split()))
    m = sum(s)/n
    v = 0.0
    for t in s:v+=(t-m)**2.0
    v = sqrt(v/n)
    print ("%.10f"%(v))



Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  }
  else if (a <= 5) {
    cout << 0 << endl;
  }
  else {
    cout << b / 2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct Edge{
    int from;
    int to;
    LL cost;
}Edge;

vector<Edge> G; // グラフ
vector<LL> D;   // 各ノードへの最短距離
int N;  // 頂点数

#define MINF -1000000000000000000

void Bellman_Ford(int a){   // a はスタート地点
    rep(i,N)D[i] = INF;
    D[a] = 0;   // 初期地点
    rep(i,N){   // N回繰り返すだけなので、indexは気にしない(頂点数)
        for(auto j : G){
            if(D[j.from] != INF && D[j.to] > D[j.from] + j.cost)D[j.to] = D[j.from] + j.cost;
        }
    }
}


// Bellman_Ford後に使用
void Nega_Search(){     // 負閉路を検知すると、その閉路に関わるノードのDを-INFに書き換える
    rep(i,N){
        for(auto j : G){
            if(D[j.to] != INF && D[j.to] > D[j.from] + j.cost)D[j.to] = MINF;
        }
    }
}


int main(){
    int M;cin >> N >> M;
    LL P;cin >> P;
    G.resize(N);
    D.resize(N);
    rep(i,M){
        int a,b;cin >> a >> b;
        LL c;cin >> c;
        a--;b--;
        G.push_back((Edge){a,b,P-c});
    }
    Bellman_Ford(0);
    Nega_Search();
    LL ans = max(-1*D[N-1],0LL);
    if(D[N-1] == MINF)cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli,lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) sort(x.begin(),x.end())
map<int,int>m;
void solve()
{
    string a;cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++)
    {
        m[a[i]]++;
    }
    for(pii i:m)
    {
        if(i.ss%2!=0)
        {
            cout<<"No\n";return;
        }
    }
    cout<<"Yes\n";

}

int main()
{
    solve();
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main()
{
	int n;
	double p;
	int a[6] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> p;
		if (p < 165.0)a[0]++;
		else if (p < 170.0)a[1]++;
		else if (p < 175.0)a[2]++;
		else if (p < 180.0)a[3]++;
		else if (p < 185.0)a[4]++;
		else a[5]++;
	}
	for (int i = 1; i < 7; i++){
		cout << i << ":";
		for (int i2 = 0; i2 < a[i-1]; i2++){
			cout << "*";
		}
		cout << endl;
	}
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UF{
    vector<int>par,sz;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N;
int dx[]={0,-1,0,1};
int dy[]={-1,0,1,0};
int x[55555],y[55555];

void solve(){
    map<pint,int>dic;
    rep(i,2*N)dic[{y[i],x[i]}]=i;
    UF uf;uf.init(2*N);
    rep(i,2*N){
        rep(d,4){
            int ny=y[i]+dy[d],nx=x[i]+dx[d];
            if(dic.find({ny,nx})==dic.end())continue;
            int tmp=dic[{ny,nx}];
            if(tmp==(i^1))continue;
            uf.unite(tmp,i);
            uf.unite(tmp^1,i^1);
        }
    }

    rep(i,N){
        if(uf.same(i*2,i*2+1)){
            puts("No");
            return;
        }
    }
    puts("Yes");
}

signed main(){
    while(scanf("%lld",&N),N){
        rep(i,N){
            char c;
            scanf("%lld%lld %c",&x[i*2],&y[i*2],&c);
            x[i*2+1]=x[i*2];y[i*2+1]=y[i*2];
            if(c=='x'){
                x[i*2+1]++;
            }
            else{
                y[i*2+1]++;
            }
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 6700
S = input()
i = 0
Mlen = 0
tmplen = 0
for i in range (0,len(S)):
    if(S[i] == 'A' or S[i] == 'G' or S[i] == 'C' or S[i] == 'T'):
        tmplen = tmplen + 1
        if(Mlen<tmplen):
            Mlen = tmplen
    else:
        tmplen = 0

print(Mlen)

Measured memory_bytes: 3060