akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<vi> f(n,vi(10));
  rep(i,n) rep(j,10) cin>>f[i][j];
  vector<vi> p(n,vi(11));
  rep(i,n) rep(j,11) cin>>p[i][j];
  
  int ans=-INF;
  for(int mask=1; mask<(1<<10); mask++){
    int tmp=0;
    rep(i,n){
      int cnt=0;
      rep(j,10) if((mask>>j&1)&&f[i][j]) cnt++;
      tmp+=p[i][cnt];
    }
    chmax(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())
 
def ss_raw():
    return input().split()
 
def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def main():
    N,M = ints_raw()
    As = [int_raw() for _ in range(M)]
    is_breake = [0]*(N+1)
    for a in As:
        is_breake[a]=1
    memo = [0]*(N+1)
    memo[0]=1
    memo[1]=1 if is_breake[1]==0 else 0
    for n in range(2,N+1):
        if is_breake[n]:
            memo[n] =0
            
        else:
            memo[n]=(memo[n-2]+memo[n-1])%DIV
    return memo[-1]

print(main())


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>

using namespace std;

const int MAX_V = 10000;
const int INF = 1 << 28;

struct edge { int to, cost; };
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
bool used[MAX_V];

int prim(){
	priority_queue<P, vector<P>, greater<P> > que;
	//cout << "V = " << V << endl;
	fill(d, d + V, INF);
	fill(used, used + V, false);
	d[0] = 0;
	que.push(P(0, 0));
	int res = 0;
	while(!que.empty()){
		P p = que.top(); que.pop();
		//cout << p.first << ' ' << p.second << endl;
		if(used[p.second]) continue;
		used[p.second] = true;
		res += p.first;
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			//cout << e.to << ' ' << e.cost << ' ' << d[e.to] << endl;
			if(d[e.to] > e.cost){
				d[e.to] = e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	return res;
}

int main(){
	int E;
	while(1){
		scanf("%d", &V);
		if(V == 0) break;
		scanf("%d", &E);
		//cin >> V >> E;
		for(int i=0;i<MAX_V;i++) G[i].clear();
		for(int i=0;i<E;i++){
			int s, t, w;
			scanf("%d,%d,%d", &s, &t, &w);
			//cout << s << ' ' << t << ' ' << w << endl;
			//cin >> s >> t >> w;
			G[s].push_back((edge){t, w});
			G[t].push_back((edge){s, w});
		}
		cout << prim() / 100 - (V - 1) << endl;
	}
	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	set <int> v;
	for(int i = 0; i < n; i++) {
		int val;
		scanf("%d", &val);
		if(v.find(val) != v.end()) {
			printf("NO\n");
			return 0;
		}
		v.insert(val);
	}
	printf("YES\n");

	return 0;
}

Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//↑templete
signed main(){

	int N, M;
	cin>>N>>M;

	vint X;
	for(int i=0;i<M;i++){
		int x;
		cin>>x;
		X.pb(x);
	}
	sort(X.begin(), X.end());

	if(M==1){
		cout<<0<<endl;
		return 0;
	}

	int sum=0;
	vint vec;
	for(int i=1;i<M;i++){
		int temp=X[i]-X[i-1];
		sum+=temp;
		vec.pb(temp);
	}
	sort(vec.begin(), vec.end(), greater<int>());
	
	for(int i=0;i<N-1 && i<M;i++)
		sum-=vec[i];
	
	cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1400
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int R = Integer.parseInt(tokens[1]);
		int result = R;
		if (N >= 10) {
		} else {
			result += 100 * (10 - N);
		}
		System.out.println(result);
	}

	void calc() {
	}

	void showResult() {

	}
}


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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s;
    cin >> t;

    for (int i = 0; i < min(s.length(), t.length()); i++) {
        string s_sub = s.substr(i, n);
        string t_sub = t.substr(0, n - i);
        if (s_sub.compare(t_sub) == 0) {
            cout << t.length() + i << endl;
            return 0;
        }
    }

    cout << 2 * n << endl;
    return 0;
}

Measured memory_bytes: 3572
def prime_decomposition(n) -> 'List[Tuple[prime,cnt]]':
    ret = []

    x = n

    divisor = 2
    cnt = 0
    while x % divisor == 0:
        x //= divisor
        cnt += 1
    if cnt > 0:
        ret.append((divisor, cnt))

    divisor = 3
    while divisor * divisor <= n:
        cnt = 0
        while x % divisor == 0:
            x //= divisor
            cnt += 1
        if cnt > 0:
            ret.append((divisor, cnt))
        divisor += 2

    if x > 1:
        ret.append((x, 1))

    return ret


n, p = map(int, input().split())

lis = prime_decomposition(p)

ret = 1
for pr, cnt in lis:
    ret *= pr ** (cnt // n)
print(ret)

#     if cnt >= n:
#         ret *= pr
# ではなく、cnt//n


Measured memory_bytes: 3064
N=int(input())
S=input()
L=[]
w=0
e_count=0
ans=N

for i in range(N):
    L.append(w)
    if S[i]=='W':
        w+=1

for i in range(N):
    ans=min(L[N-i-1]+e_count,ans)
    if S[N-i-1]=='E':
            e_count+=1

print(ans)

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

void solve() {
    int n, m, k;
    std::cin >> n >> m >> k;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    std::vector<int> ys(m);
    for (auto& y : ys) std::cin >> y;

    int ans = *std::min_element(xs.begin(), xs.end()) +
              *std::min_element(ys.begin(), ys.end());
    while (k--) {
        int i, j, c;
        std::cin >> i >> j >> c;
        --i, --j;
        ans = std::min(ans, xs[i] + ys[j] - c);
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


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

  int N ;
  cin >> N ;
  map<string,int> mp ;
  rep(i,N){
    string S ;
    cin >> S ;
    mp[S] = mp[S] + 1 ;
  }
  int count = 0 ;
  for(auto p : mp){
    auto A = p.second ;
    count = max(count,A) ;
  }
  vector<string> vec ;
  for(auto p : mp){
    auto B = p.first ;
    auto C = p.second ;
    if(C == count) vec.push_back(B) ;
  }
  sort(vec.begin(),vec.end());
  rep(i,vec.size()) cout << vec.at(i) << endl;
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll a[n],b[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++) cin>>b[i];
  
  ll c[n];
  ll ans=0;
  for(i=0;i<29;i++){
    for(j=0;j<n;j++){
      c[j]=b[j]&((1<<(i+1))-1);
    }
    sort(c,c+n);
    ll p;
    ll q=0;
    for(j=0;j<n;j++){
      p=a[j]&((1<<(i+1))-1);
      q+=upper_bound(c,c+n,(1<<(i+2))-1-p)-lower_bound(c,c+n,(1<<(i+1))+(1<<i)-p);
      q+=upper_bound(c,c+n,(1<<(i+1))-1-p)-lower_bound(c,c+n,(1<<i)-p);
      q%=2;
    }
    if(q&1) ans+=(1<<i);
  }
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef pair<int,int> pii;
// tree <pii,null_type,greater<pii>,rb_tree_tag,tree_order_statistics_node_update> tr;
// cin.tie(0);
// std::ios::sync_with_stdio(false);
typedef long long LL;
const LL N = 205;
const LL M = 205;
const LL INF = 0x3f3f3f3f;
const double Pi = acos(-1);
const LL MOD = 1e9+7;
const double eps = 1e-8;
LL n,m;
LL s[N];
LL S,T;
struct edge
{
    LL to,cap,rev;
};
vector <edge> G[N];
LL level[N],iter[N];
LL vis[N];
inline void add_edge(LL from,LL to,LL cap)
{
    // cout<<"ADD "<<from<<" "<<to<<" "<<cap<<endl;
    G[from].push_back((edge){to,cap,(int)G[to].size()});
    G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
inline void bfs (LL s)
{
    memset(level,-1,sizeof(level));
    queue <int> que;
    level[s]=0;
    que.push(s);
    while (!que.empty())
    {
        LL v=que.front();
        que.pop();
        for (LL i=0;i<G[v].size();i++)
        {
            edge &e= G[v][i];
            if (e.cap>0&&level[e.to]<0)
            {
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}
inline LL dfs(LL v,LL t,LL f)
{
    if (v==t)
        return f;
    for (LL &i=iter[v];i<G[v].size();i++)
    {
        edge &e=G[v][i];
        if (e.cap>0&&level[v]<level[e.to])
        {
            LL d=dfs(e.to,t,min(f,e.cap));
            if (d>0)
            {
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
inline LL max_flow(LL s,LL t)
{
    LL flow=0;
    for (;;)
    {
        bfs(s);
        if (level[t]<0)
            return flow;
        memset(iter,0,sizeof(iter));
        LL f;
        while ((f=dfs(s,t,INF))>0)
            flow+=f;
    }
}

inline void ini()
{
    S=0,T=n+1;
    for (LL i=0;i<=n+1;i++)
        G[i].clear();
}
int main()
{
    while (~scanf("%lld",&n))
    {
        ini();
        LL ans = 0;
        for (LL i=1;i<=n;i++)
        {
            scanf("%lld",&s[i]);
            if (s[i]>=0)
                ans += s[i];
            if (s[i]<0)
                add_edge(i,T,-s[i]);
            else
                add_edge(S,i,s[i]);
        }
        for (LL i=1;i<=n;i++)
            for (LL j=i+i;j<=n;j+=i)
                add_edge(j,i,INF);
        LL tmp = max_flow(S,T);
        // cout<<"bug "<<ans<<" "<<tmp<<endl;
        printf("%lld\n",ans-tmp);
    }
    return 0;
}

/*

6
1 2 -6 4 5 3

6
100 -100 -100 -100 100 -100

5
-1 -2 -3 -4 -5

2
-1000 100000

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T>
class BIT
{
//bit[x]
//manage range of bit[x] is (x & -x)
//
public:
	static const int n = 2*110000;
	T bit[n] = {};
	void add(int a, T w)
	{
		for (int x = a; x <= n; x += x & -x)
		{
			bit[x] += w;
		}
	}
	T sum(int a)
	{
		T ret = 0;
		for (int x = a; x > 0; x -= x & -x)
		{
			ret += bit[x];
		}
		return ret;
	}
 
};
 
int main()
{
	string s;
	cin >> s;
	int hairetsu[2*110000];
	int n = s.size();
	for (int i = 1; i <= n; ++i)
	{
		hairetsu[i] = (s[i-1] == 'B'?1:0);
	}
 
	int bla = 0;
	long long int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if(hairetsu[i])
		{
			++bla;
		}
		else
		{
			ans += bla;
		}
	}
 
	// BIT<long long int> BT;
	// for (int i = 1; i <= n; ++i)
	// {
	// 	BT.add(i, hairetsu[i]);
	// 	if (hairetsu[i] == 0)
	// 	{
	// 		ans += BT.sum(i);
	// 	}
	// 	// cout << i - BT.sum(hairetsu[i]) << " ";
	// }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include <stdio.h>

int main(){
	int N,M;
	scanf("%d %d",&N,&M);

	if(N-M>=2 || M-N>=2){
		printf("0");
		return 0;
	}
	int a=1;
	if(N==M)a=2;

	int i;
	long long num_N=1,num_M=1;
	for(i=1;i<=N;i++){
		num_N=num_N*i;
		num_N=num_N%1000000007;
	}
	for(i=1;i<=M;i++){
		num_M=num_M*i;
		num_M=num_M%1000000007;
	}

	long long num;
	num=(num_N*num_M*a)%1000000007;
	printf("%lld",num);
}

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

int main()
{
 int W,H,x,y,r,a,b,c,d;
 cin>>W>>H>>x>>y>>r;
 if(W>=x+r)a=1;else a=0;
 if(x-r>=0)b=1;else b=0;
 if(H>=y+r)c=1;else c=0;
 if(y-r>=0)d=1;else d=0;

 if(a==b&&c==d){
    if(a==c&&a==1){cout<<"Yes\n";
    }else cout<<"No\n";
 }else cout<<"No\n";
           
  return 0;
}

Measured memory_bytes: 1124
INF=10**20
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
xyh=sorted(xyh,key=lambda xyh:xyh[2],reverse=True)
for i in range(101):
    for j in range(101):
        res=-INF
        T=True
        for k in range(N):
            tmp=xyh[k][2]+abs(xyh[k][0]-i)+abs(xyh[k][1]-j)
            if(xyh[k][2]>0):
                if(res==-INF):
                    res=tmp
                elif(res!=tmp):
                    T=not T
                    break
            elif(xyh[k][2]==0):
                if(tmp<res):
                    T=not T
                    break
        if T:
            print(i,j,res)
            exit()


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

int main()
{
	int N = 0;
	cin >> N;
	int A[N];
	map<int, int> m;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		m[A[i]]++;
	}
	int twos = 0;
	for(map<int, int>::iterator it = m.begin(); it != m.end(); it++){
		if(!(it->second % 2)) twos++;
	}
	int minus = 0;
	if(twos % 2) minus = 1;
	cout << m.size() - minus << endl;

	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define N 100010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int d[N],n,ct[20],Ans,F[N],S[N];
int main()
{
	// freopen("read.in","r",stdin);
	for(int i=1;i<(1<<16);i++)
		F[i]=F[i-(i&-i)]^(__builtin_popcount((i&-i)-1));
	// for(int i=0;i<=10;i++) printf("%d\n",F[i]);
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read()+1, v=read()+1, w=read();
		d[u]^=w; d[v]^=w;
	}
	// for(int i=1;i<=n;i++) printf("%d ",d[i]); puts("");
	for(int i=1;i<=n;i++) ct[d[i]]++;
	// for(int i=1;i<16;i++) printf("%d ",ct[i]); puts("");
	for(int i=1;i<16;i++) Ans+=ct[i]/2,ct[i]&=1;
	// memset(S,0x3f,sizeof S); S[0]=0;
	for(int i=1;i<(1<<16);i++)
	{
		for(int j=i;j;j=(j-1)&i)
			if(!F[j]) S[i]=max(S[i],S[i^j]+1);
	}
	int Ret=0; for(int i=1;i<16;i++) Ret|=(ct[i]<<i);
	// cout << Ret << endl;
	cout << Ans+__builtin_popcount(Ret)-S[Ret] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int cnt[12];

int main()
{
  int X;
  for (int i=0;i<3;i++){
    cin>>X;
    cnt[X]++;
  }
  if (cnt[5]==2 && cnt[7]==1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = 0; i < 2; i++) {
		ans += max(A, B);
		if (max(A, B) == A) A--;
		else B--;
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
/*

░█▀▀▄ ▀█▀ ░█▄─░█ ░█▀▀▀ ░█▀▀▀█ ░█─░█ 
░█─░█ ░█─ ░█░█░█ ░█▀▀▀ ─▀▀▀▄▄ ░█▀▀█ 
░█▄▄▀ ▄█▄ ░█──▀█ ░█▄▄▄ ░█▄▄▄█ ░█─░█

*/
 
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;++i)
#define fr(i,a,b) for(ll i=a;i>=b;--i)
#define fa(i,a,b) for(auto i=a;i!=b;++i)
#define beg begin()
#define end end()
#define vi vector<int>
#define vl vector<long long>
#define pi pair<int,int>
#define pl pair<long long,long long>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false)

 
int main()
{
    fastio;
    cin.tie(NULL);
    ll t;
    cin>>t;
    unordered_map<string,int>umap;
    while(t--)
    {
        string str;
        cin>>str;
        umap[str]++;
    }
    cout<<"AC x "<<umap["AC"]<<endl;
    cout<<"WA x "<<umap["WA"]<<endl;
    cout<<"TLE x "<<umap["TLE"]<<endl;
    cout<<"RE x "<<umap["RE"]<<endl;

    return 0;
}
         

Measured memory_bytes: 3660
h, w = map(int, input().split())
a = [["#"] * (w + 1)]
for _ in range(h):
    a.append(["#"] + list(input()))
mod = 10 ** 9 + 7

dp = [[0] * (w + 1) for _ in range(h + 1)]
for hi in range(1, h + 1):
    for wi in range(1, w + 1):
        if hi == 1 and wi == 1:
            dp[hi][wi] = 1
            continue
        if a[hi][wi] == ".":
            dp[hi][wi] = dp[hi-1][wi] + dp[hi][wi-1]
            dp[hi][wi] %= mod

ans = dp[h][w]
print(ans)


Measured memory_bytes: 56340
# ABC107C - Candles (ARC101C)
def main():
    N, K, *X = map(int, open(0).read().split())
    cand = [r - l + min(abs(l), abs(r)) for l, r in zip(X, X[K - 1 :])]
    ans = min(cand)
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);

    int x;
    cin >> x;
    string ans = (x>=30)? "Yes" : "No";
    cout << ans << "\n";
}

Measured memory_bytes: 3628
import sys


def check_bipartite(s, links, visited):
    q = [(s, 0)]
    is_bipartite = True
    count = 0
    while q:
        v, color = q.pop()
        if visited[v] != -1:
            if visited[v] != color:
                is_bipartite = False
            continue
        visited[v] = color
        count += 1
        new_color = color ^ 1
        for u in links[v]:
            if visited[u] != -1:
                if visited[u] != new_color:
                    is_bipartite = False
                continue
            q.append((u, new_color))
    return is_bipartite, count


n, m = map(int, sys.stdin.buffer.readline().split())
links = [set() for _ in range(n)]
mp = map(int, sys.stdin.buffer.read().split())
for u, v in zip(mp, mp):
    u -= 1
    v -= 1
    links[u].add(v)
    links[v].add(u)

visited = [-1] * n
count_bipartite = 0
count_non_bipartite = 0
count_isolated = 0
ans = 0
for v in range(n):
    if visited[v] != -1:
        continue
    is_bipartite, count = check_bipartite(v, links, visited)
    if count == 1:
        count_isolated += 1
    elif is_bipartite:
        count_bipartite += 1
    else:
        count_non_bipartite += 1

ans = count_isolated * (n * 2 - count_isolated)
ans += count_non_bipartite * (count_non_bipartite + count_bipartite * 2)
ans += count_bipartite ** 2 * 2

print(ans)


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

int main() {
    string S;
    int val = 700;
    int coun = 0;

    cin >> S;
    for (int i = 0; i < 3; i++){
        if (S[i] == 'o'){
            coun += 1;
        }
    }

    cout << (val + 100*coun) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int n, tsum=0, hsum=0, i;
    char t[100], h[100];
    
    scanf("%d", &n);

    for(i=0; i<n; i++){
        scanf("%s %s", t, h);
        if(strcmp(t, h) == 0){
            hsum++;
            tsum++;
        }else if(strcmp(t, h) < 0){
            tsum = tsum + 3;
        }else if(strcmp(t, h) > 0){
            hsum = hsum + 3;
        }
    }
    printf("%d %d\n", hsum, tsum);
    
    return 0;
}



Measured memory_bytes: 2036
#include <stdio.h>

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

	if ((b - a) / 2 < k) {
		for (int i = a; i <= b; i++) {
			printf("%d\n", i);
		}
	}
	else {
		for (int i = a; i < (a+k); i++) {
			printf("%d\n", i);
		}
		for (int i = (b-k+1); i <= b; i++) {
			printf("%d\n", i);
		}
	}
}

Measured memory_bytes: 128
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);

const a: number[][] = [];

for (let i = 0; i < n; i++) {
	const tmp = input[i + 1].split(" ").map((x: string): number => +x);
	a.push(tmp);
}

const f: number[] = [k];
let flg = 1;
for (let i = 0; i < 30; i++) {
	if ((flg & k) != 0) {
		const tmp = k;
		f.push((k >> (i + 1) << (i + 1)) + (1 << i) - 1); // 下からi桁目を0に、そこから下全て1に
	}
	flg <<= 1;
}

let ans = -1;
for (const s of f) {
	let result = 0;
	for (let i = 0; i < n; i++) {
		if ((s | a[i][0]) == s) {
			result += a[i][1];
		}
	}
	ans = Math.max(ans, result);
}
console.log(ans);


Measured memory_bytes: 52172
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = b-a;
    if(k%2 == 0) ans = a-b;
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<tuple<int,int,int64_t>> p(M+1);
  for(int i=0;i<M;i++){
    int a,b;
    int64_t c;
    cin>>a>>b>>c;
    a--,b--;
    p[i]=make_tuple(a,b,c);
  }
  p[M]=make_tuple(167167,167167,167167);
  sort(p.begin(),p.end());
  vector<int64_t> l(N);
  priority_queue<int64_t,vector<int64_t>,greater<int64_t>> pq;
  priority_queue<int64_t,vector<int64_t>,greater<int64_t>> pqo;
  pq.push(0);
  int a=0;
  vector<vector<int64_t>> G(N);
  G[0].push_back(0);
  for(int i=0;i<N;i++){
    l[i]=pq.top();
    if(i==N-1){
      break;
    }
    while(get<0>(p[a])==i){
      int64_t D=get<2>(p[a])+l[i];
      G[get<1>(p[a])].push_back(D);
      pq.push(D);
      a++;
    }
    for(auto x:G[i]){
      pqo.push(x);
    }
    while(pq.top()==pqo.top()&&!pq.empty()&&!pqo.empty()){
      pq.pop();
      pqo.pop();
    }
    if(pq.empty()){
      l[N-1]=-1;
      break;
    }
  }
  cout<<l[N-1]<<endl;
    
}

Measured memory_bytes: 11420
#include <stdio.h>
 
int main(){
  int N,count = 0,i,j;
  int P[N];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]!=j+1){
      count = count +1;
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    


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


Measured memory_bytes: 2044
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		String[][] alphabet = new String[2][27];
		alphabet[0][0] = "a";

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] strAry = str.split("");
		char charAry[] =str.toCharArray();
		for (int i = 0; i < strAry.length; i++) {
			if (Character.isUpperCase(charAry[i])) {
				strAry[i] = strAry[i].toLowerCase();
			} else if(Character.isLowerCase(charAry[i])) {
				strAry[i] = strAry[i].toUpperCase();
			}
			System.out.print(strAry[i]);
		}
		System.out.println("");
	}

}

Measured memory_bytes: 27396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  string s;
  cin >> s;

  if (s == "A"){
    cout << "T" << endl;
  }
  else if (s == "T"){
    cout << "A" << endl;
  }
  else if (s == "G"){
    cout << "C" << endl;
  }
  else {
    cout << "G" << endl;
  }


  return 0;
}


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

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int cost1 = abs(a2 - a1) + abs(a3 - a2);
    int cost2 = abs(a1 - a3) + abs(a3 - a2);
    int cost3 = abs(a2 - a1) + abs(a1 - a3);

    cout << min(cost1, min(cost2, cost3)) << endl;

    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
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 printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string X;
    cin >> X;
    ll ans = 0;
    ll N = X.size();
    ll s = 0;
    rep(i,0,N){
        if(X[i] == 'S'){
            s++;
        }else{
            if(s > 0){
                s--;
                ans += 2;
            }
        }

    }
    ans = N - ans;
    print(ans);
    

}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> maze(h);
  for(ll i=0;i<h;i++) cin >> maze[i];
  set<ll> y,x;
  for(ll i=0;i<h;i++) {
    ll f=1;
    for(ll j=0;j<w;j++) {
      if(maze[i][j]=='#')f=0;
    }
    if(f) y.insert(i);
  }
  for(ll i=0;i<w;i++) {
    ll f=1;
    for(ll j=0;j<h;j++) {
      if(maze[j][i]=='#')f=0;
    }
    if(f) x.insert(i);
  }
  for(ll i=0;i<h;i++) {
    if(y.count(i)) continue;
    for(ll j=0;j<w;j++) {
      if(x.count(j)) continue;
      cout << maze[i][j];
    }
    cout << endl;
  }
}

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

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var line = ReadLine().Split(' ').Select(value => int.Parse(value)).ToArray();
            var n = line[0];
            var k = line[1];
            var aArray = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
            
            for(var i = k; i < n; i++)
            {
                WriteLine(aArray[i] > aArray[i - k] ? "Yes" : "No");
            }
        }
    }
}


Measured memory_bytes: 47208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
    string s;
    cin >> s;
    int c = 0, m = -1;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R')
            c++;
        else
        {
            c = 0;
        }
        m = max(m, c);
    }
    cout << m << endl;
}

Measured memory_bytes: 3624
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (n, a): (usize, usize);
    input!(n);
    input!(a);
    p(n * n - a);
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

//　呼び出し
func main() {
	// 共通
	sc := NewScanner()

	// *** NextInt
	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()
	d := sc.NextInt()
	e := sc.NextInt()

	k := sc.NextInt()

	if abs(a-b) > k {
		fmt.Println(":(")
	} else if abs(b-c) > k {
		fmt.Println(":(")
	} else if abs(d-c) > k {
		fmt.Println(":(")
	} else if abs(d-e) > k {
		fmt.Println(":(")
	} else if abs(a-c) >k{
		fmt.Println(":(")
	} else if abs(a-d) >k {
		fmt.Println(":(")
	} else if abs(a-e) > k {
		fmt.Println(":(")
	} else if abs(b-d) > k {
		fmt.Println(":(")
	} else if abs(b-e) > k {
		fmt.Println(":(")

	} else if abs(c-d) > k {
		fmt.Println(":(")

	}  else if abs(c-e) > k {
		fmt.Println(":(")

	} else {
		fmt.Println("Yay!")
	}

}

// ======================= 以下ライブラリ ========================

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// *** int
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

// *** int64
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

// **** float
func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

// *** []int 一行読み取って
func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

// *** string 一行読み読み取って
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}


// ====================以下共通部分==================================
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}

func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}

func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

Measured memory_bytes: 640
int main( void )
{
    long S;
    long hour;
    long minute;
    long second;
    
    scanf("%ld",&S);
    hour = S / (60 * 60); 
    minute = ( S % (60 * 60) ) / 60;
    second = ( S % (60 * 60) ) % 60;
        
    printf("%ld:%ld:%ld\n",hour,minute,second);
    
    return 0;
}

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

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

    char alpha[] = {'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                    'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                    's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

    vector<char> ans;
    while(true) {
        int m = N % 26;
        ans.push_back(alpha[m]);
        // cout << "PUSH:m=" << m << ", N=" << (N / 26) << ", alpha=" << alpha[m] << endl;
        if(N <= 26) {
            break;
        }
        N /= 26;
        if(m == 0) {
            N--;
        }
    }
    reverse(ans.begin(), ans.end());
    for(char c : ans) {
        cout << c;
    }
    cout << endl;

    return 0;
}

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

int main(){

	int a, b, mochi;
	cin >> a >> b;
	mochi = a+b;

	if(a%3 == 0){
		cout <<"Possible\n";
	}
	else if(b%3 == 0){
		cout <<"Possible\n";
	}
	else if(mochi%3 == 0){
		cout <<"Possible\n";
	}
	else{
		cout <<"Impossible\n";
	}

	return 0;

}

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  REP(i, n) cin >> p[i];
  vector<int> rev_cnt(n - k + 1);
  int j = 1, cnt = 0;
  REP(i, n - k + 1) {
    while (j < i + k) {
      if (p[j - 1] > p[j]) {
        cnt++;
      }
      j++;
    }
    rev_cnt[i] = cnt;
    if (p[i] > p[i + 1]) {
      cnt--;
    }
  }
  vector<int> same(n - k + 1);
  set<int> st;
  j = 0;
  REP(i, n - k) {
    while (j < i + k + 1) {
      st.insert(p[j]);
      j++;
    }
    int mn = *st.begin();
    int mx = *prev(st.end());
    if (mn == p[i] && mx == p[j - 1]) {
      same[i + 1] = 1;
    }
    st.erase(p[i]);
  }
  int ans = 0, z = 0;
  REP(i, n - k + 1) {
    if (!same[i]) {
      if (rev_cnt[i]) {
        ans++;
      } else {
        z++;
      }
    }
  }
  cout << ans + (0 < z) << endl;
  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const int INF = 2000000000;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
    string s;
    cin >> s;
    
    if (s[1] == s[0] || s[2] == s[1] || s[3] == s[2]) cout << "Bad" << endl;
    else cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#include <algorithm>
using namespace std;

int pan[10][10];

int H, W, C;

int change(int c0, int c1, int x, int y, int panel[10][10]) {
	
	if ( x > 9 || y > 9 ) { return 0; }
	if ( x < 0 || y < 0 ) { return 0; }
	
	if ( panel[x][y] == c0 ) {
		panel[x][y] = c1;
		
		int ret = 1;
		ret += change(c0, c1, x+1, y, panel);
		ret += change(c0, c1, x, y+1, panel);
		ret += change(c0, c1, x-1, y, panel);
		ret += change(c0, c1, x, y-1, panel);
		
		return ret;
	} else {
		return 0;
	}
}


int main(void) {
	
	while(true) {
		
		scanf("%d %d %d", &H, &W, &C);
		
		if ( H==0 && W==0 && C==0 ) { break; }
		
		fill(pan[0], pan[0]+10*10, -1);
		for(int x=0; x<H; x++) {
			for(int y=0; y<W; y++ ) {
				scanf("%d", &pan[x][y]);
			}
		}
		
		int maax = 0;
		
		for(int col=0; col<(6*6*6*6); col++) {
			int prevcolor = pan[0][0];
			
			int nowpan[10][10];
			//TODO std::copy
			memcpy(nowpan, pan, 10*10*sizeof(int));
			
			
			int colordiv = col;
			int ret = -1;
			for(int i=0; i<4; i++) {
				int nowcolor = (colordiv%6)+1;
				colordiv /= 6;
				
				//printf("%d->", nowcolor);
				
				if ( prevcolor == nowcolor ) {
					continue;
				}
				
				change(nowpan[0][0], nowcolor, 0, 0, nowpan);
				prevcolor = nowcolor;
			}
			
			if ( prevcolor != C ) {
				change(nowpan[0][0], C, 0, 0, nowpan);
			}
			ret = change(C, 0, 0, 0, nowpan);
			
			/*
			memcpy(nowpan, pan, 10*10*sizeof(int));
			change(nowpan[0][0], 6, 0, 0, nowpan);
			printf("\n");
			for(int x=0; x<H; x++) {
				for(int y=0; y<W; y++ ) {
					printf("%d ", nowpan[x][y]);
				}
				printf("\n");
			}
			
			change(nowpan[0][0], 3, 0, 0, nowpan);
			printf("\n");
			for(int x=0; x<H; x++) {
				for(int y=0; y<W; y++ ) {
					printf("%d ", nowpan[x][y]);
				}
				printf("\n");
			}
			change(nowpan[0][0], 4, 0, 0, nowpan);
			printf("\n");
			for(int x=0; x<H; x++) {
				for(int y=0; y<W; y++ ) {
					printf("%d ", nowpan[x][y]);
				}
				printf("\n");
			}
			change(nowpan[0][0], 2, 0, 0, nowpan);
			printf("\n");
			for(int x=0; x<H; x++) {
				for(int y=0; y<W; y++ ) {
					printf("%d ", nowpan[x][y]);
				}
				printf("\n");
			}
			change(nowpan[0][0], 5, 0, 0, nowpan);
			printf("\n");
			for(int x=0; x<H; x++) {
				for(int y=0; y<W; y++ ) {
					printf("%d ", nowpan[x][y]);
				}
				printf("\n");
			}
			break;
			*/
			
			if ( maax < ret ) { maax = ret;

			
			}
		}
		
		printf("%d\n", maax );
		
	}
}

Measured memory_bytes: 1016
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;

const int INF = 0x3f3f3f3f;

const int MAX_N = 1000000;
const int MAX_len = 1000000;


pii calc(char str[]){
	int len = strlen(str);
	int least = 0, sum = 0;
	for (int i = 0; i < len; ++i){
		if(str[i] == '(')	sum += 1;
		if(str[i] == ')')	sum -= 1;
		least = min(sum,least);
	}
	return pii(least,sum);
}

char str[MAX_len+1];
pii x[MAX_N];

priority_queue<pii> que;

bool check(int N){
	int sum = 0;
	for (int i = 0; i < N; ++i){
		if(x[i].first >= 0)	sum += x[i].second;
		else{
			if(x[i].second >= 0)
				que.push(x[i]);
		}
	}
	while(!que.empty()){
		pii xi = que.top();	que.pop();
		if(sum + xi.first < 0)	return false;
		sum += xi.second;
	}


	for (int i = 0; i < N; ++i){
		if(x[i].first < 0 && x[i].second < 0){
			que.push(pii(x[i].second-x[i].first,-x[i].first));
		}
	}

	while(!que.empty()){
		pii xi = que.top();	que.pop();
		if(sum - xi.second < 0)	return false;
		sum += xi.first-xi.second;
	}
	assert(sum == 0);

	return true;
}

int main(){
	int N;	scanf("%d",&N);
	int sum = 0;
	for (int i = 0; i < N; ++i){
		scanf(" %s",str);
		x[i] = calc(str);
		sum += x[i].second;
	}
	if(sum){
		puts("No");
		return 0;
	}
	assert(sum == 0);
	if(check(N))	puts("Yes");
	else			puts("No");
}



Measured memory_bytes: 14852
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<int> G[100000+2];
vector<int> visit(100000+2, -1);
int color = 0;

void dfs(int x){

    if(visit[x] > -1)
        return;
    visit[x] = color;

    for (int i = 0; i < G[x].size(); ++i) {
        dfs(G[x][i]);
    }
}


int main(void) {

    int n,m; cin>>n>>m;
    for (int i = 0; i < m; ++i) {
        int s,t; cin>>s>>t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    for (int i = 1; i < n; ++i) {
        if(visit[i]<0){
            color++;
            dfs(i);
        }
    }

    int q; cin>>q;
    for (int i = 0; i < q; ++i) {
        int s,t; cin>>s>>t;
        if(visit[s]==visit[t]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;

    }

    return 0;
}


Measured memory_bytes: 11816
--string.char(97)はa
local t = {}
local str = io.read("*l")
for i = 97, 122 do
  t[i] = 0
end
for i = 1, #str do
  local num = string.byte(string.sub(str, i, i))
  t[num] = t[num] + 1
end
for i = 97, 122 do
  if t[i] % 2 == 1 then
    print("No")
    os.exit()
  end
end
print("Yes")

Measured memory_bytes: 376
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll mx = 0LL, ans = 0LL;
	rep(i, n){
		mx = max(mx, a[i]);
		if(mx > a[i]) ans += mx - a[i];
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4776
'use strict';

const Main = input => {
  const howmany = parseInt(input, 10);
  const amari = howmany % 3;
  const Answer = () => {
    switch (amari) {
      case 1:
        return (howmany - 1) / 3;

      case 2:
        return (howmany - 2) / 3;

      case 0:
        return howmany / 3;

      default:
      return 0;
    }
  };
  console.log(Answer());
};
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <stdio.h>

int main (void){
    int a, b;
    
    scanf("%d %d", &a , &b);
    
    if(a < b){
        puts("a < b");
    }else if(a > b){
        puts("a > b");
    }else if(a == b){
        puts("a == b");
    }
    
    
    return 0;
    
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum = 0;
  cin >> N;
  for(int i = 1; i <= 9; i++){
    sum += (N%(int)(pow(10,i)))/(int)(pow(10,i-1));
  }
  cout << (N % sum == 0 ? "Yes" : "No") << endl; 
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cout << fixed;
	cout << setprecision(11);

	double a, b, h, m;
	cin >> a >> b >> h >> m;
	h+=(m/60);
	double angle=(double)abs((h*30)-(m*6));
	if(angle>180)
        angle=360-angle;
    cout << sqrt((a*a)+(b*b)-(2*a*b*cos(angle*M_PI/180.0))) << endl;

	return 0;
}


Measured memory_bytes: 4304
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define each(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
int w, h;
char m[20][20];
int n, g[10], d[10], s[10], e[10];
int dp[2][20][20][1 << 10];

int main(){
	while(cin >> w >> h, h){
		int y, x;
		rep(i, h) rep(j, w){
			cin >> m[i][j];
			if(m[i][j] == 'P') y = i, x = j;
		}
		cin >> n;
		rep(i, n) cin >> g[i] >> d[i] >> s[i] >> e[i];
		
		memset(dp[0], -1, sizeof(dp[0]));
		dp[0][y][x][0] = 0;
		
		int ans = 0;
		int cur = 0, next = 1;
		rep(t, 100){
			memset(dp[next], -1, sizeof(dp[next]));
			
			rep(y, h) rep(x, w) rep(k, 1 << 10) if(dp[cur][y][x][k] >= 0){
				vector<pi> item;
				
				rep(dir, 4){
					int ny = y + dy[dir], nx = x + dx[dir];
					if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
					if(!isdigit(m[ny][nx])) continue;
					
					int mx = 0;
					rep(l, n) if(g[l] == m[ny][nx] - '0' && s[l] <= t && t < e[l])
						mx = max(mx, d[l]);
					if(mx) item.pb(mp(m[ny][nx] - '0', mx));
				}
				rep(b, 1 << item.size()){
					int ncost = dp[cur][y][x][k];
					int nk = k;
					
					rep(l, item.size()) if(b & 1 << l){
						if(nk & 1 << item[l].first) goto FAIL;
						ncost += item[l].second;
						nk |= 1 << item[l].first;
					}
					rep(d, 4){
						int ny = y + dy[d], nx = x + dx[d];
						if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
						if(isdigit(m[ny][nx])) continue;
						if(dp[next][ny][nx][nk] < 0 || dp[next][ny][nx][nk] > ncost){
							dp[next][ny][nx][nk] = ncost;
							ans = max(ans, ncost);
						}
					}
					FAIL:;
				}
			}
			swap(cur, next);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

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

  cout<<max(0LL,a-b*2)<<endl;


}

Measured memory_bytes: 256