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

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    long long temp;
  
    if (x % d == 0) temp = x / d;
    else temp = x / d + 1;
    if (k < temp) {
        printf("%lld\n", x - k * d);
        return 0;
    }
    k -= temp;
    x -= (temp * d);
    if (k % 2 == 0) printf("%lld\n", abs(x));
    else {
        printf("%lld\n", abs(x + d));
    }
    return 0;
}

Measured memory_bytes: 3768
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;

int main(int argc, char *argv[]) {
  ll n, m;
  ll a[2001] = {}, b[2001] = {}, c[2001] = {};
  cin >> n >> m;
  rep(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }

  ll distance[2001] = {};
  rep(i, 2001) distance[i] = INF;
  distance[0] = 0;

  rep(i, n-1) {
    rep(j, m) {
      if (distance[a[j] - 1] == INF)
        continue;
      if (distance[b[j] - 1] > distance[a[j] - 1] + c[j]) {
        distance[b[j] - 1] = distance[a[j] - 1] + c[j];
      }
    }
  }
  ll ans = distance[n - 1];

  bool negative[2001] = {};
  rep(i, 2001) negative[i] = false;
  rep(i, n) {
    rep(j, m) {
      if (distance[a[j] - 1] == INF)
        continue;
      if (distance[b[j] - 1] > distance[a[j] - 1] + c[j]) {
        distance[b[j] - 1] = distance[a[j] - 1] + c[j];
        negative[b[j] - 1] = true;
      }
      if (negative[a[j] - 1] == true)
        negative[b[j] - 1] = true;
    }
  }

  if (negative[n - 1])
    cout << "inf" << endl;
  else
    cout << -ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    int odd = 0;
    for (int i = 0; i < N; i++) {
      if (sc.nextInt()%2 == 1) odd++;
    }
    
    int even = N-odd;
    long evenComb = 0;
    for (int i = 0; i <= even; i++) {
      evenComb += comb(even, i);
    }
    
    long oddComb = 0;
    for (int i = 1; i <= odd; i+=2) {
      oddComb += comb(odd, i)*evenComb;
    }
    
    System.out.println(P == 1
      ? oddComb : (1L<<N)-oddComb);
  }
  private static long comb(int n, int r) {
    if (r == 0) {
      return 1;
    } else {
      return comb(n, r-1)*(n-r+1)/r;
    }
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int msi[51][51];

int main(){
    int n,m;
    cin>>n>>m;
    char ms[n][m];
    rep(i,n){
        rep(j,m){
            char c;
            cin>>c;
            ms[i][j]=c;
        }
    }
    
    rep(i,n){
        rep(j,m){
            
            if(ms[i][j]=='#'){
                
                for(int x=-1;x<2;x++){
                    for(int y=-1;y<2;y++){
                        if(i+x>=0&&i+x<n){
                            if(j+y>=0&&j+y<m){
                                msi[i+x][j+y]++;
                            }
                        }
                    }
                    msi[i][j]=10000;
                }
            }
        }
        
    }
    rep(i,n){
        rep(j,m){
            
            if(msi[i][j]>=10000){
                cout<<'#';
            }else{
                cout<<msi[i][j];
            }
        }
        cout<<endl;
    }
    
    
return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string s; cin >> s;
  ll w = 0;
  ll ans = 0;
  
  for(int i = (int)s.size()-1;i>=0;i--) {
    w += (s[i] == 'W');
    ans += ((s[i] == 'B') ? w : 0);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<cmath>
#include<stdlib.h>
#include<algorithm>
#include<iomanip>

int main() {
        int n;
        double x[100], y[100], one, two, three, inf, maxD, temp;
        cin >> n;
        one = 0;
        two = 0;
        three = 0;
        for(int i = 0; i < n; i++) {
                cin >> x[i];
        }
        for(int i = 0; i < n; i++) {
                cin >> y[i];
        }
        inf = abs(x[0] - y[0]);
        for(int i = 0; i < n; i++) {
                temp = abs(x[i] - y[i]);
                one += abs(temp);
                two += pow(temp, 2);
                three += pow(abs(temp), 3);
                inf = max(inf, abs(temp));
        }
        cout << fixed << setprecision(8);
        cout << one << endl;
        cout << sqrt(two) << endl;
        cout << cbrt(three) << endl;
        cout << inf << endl;
        return 0;
}

Measured memory_bytes: 3452
#include<iostream>
using namespace std;
int main()
{
	int x, n, y, z=0, i, t;
	cin>>n;
	if(n>=1 && n<=100){
			z=800*n;
		if(n>15){
			i=n/15;
			t=z-(i*200);
			cout<<t;
		}
		else{
			cout<<z;
		}
	}
	else{
		cout<<"error";
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		while(true){
			s[2]-=s[1];
			s[0]-=s[3];
			if(s[2]<=0) { Console.WriteLine("Yes");return;}
			if(s[0]<=0) { Console.WriteLine("No");return;}
		}
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27408
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 505;
const int MAXM = 250005;

int n, cur_l = 1, cur_r = 1, cnt_l[MAXN], cnt_r[MAXN], p[MAXN], a[MAXN], b[MAXM];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read(), p[i] = i, b[a[i]] = i, cnt_l[i] = i - 1, cnt_r[i] = n - i;
	sort(p + 1, p + n + 1, [&](int x, int y) { return a[x] < a[y]; });
	for (int i = 1; i <= n * n; i ++)
		if (!b[i])
		{
			while (cur_l <= n && (a[p[cur_l]] < i || !cnt_l[p[cur_l]]))
				cur_l ++;
			if (cur_l <= n)
				b[i] = p[cur_l], cnt_l[p[cur_l]] --;
			else
			{
				while (cur_r <= n && !cnt_r[p[cur_r]])
					cur_r ++;
				if (cur_r > n || a[p[cur_r]] > i)
					return puts("No"), 0;
				b[i] = p[cur_r], cnt_r[p[cur_r]] --;
			}
		}
	puts("Yes");
	for (int i = 1; i <= n * n; i ++)
		printf("%d%c", b[i], i == n * n ? '\n' : ' ');
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    string s = to_string(N);
    string ans = "No";
    for (int i=0; i<s.length(); i++){
        if (s[i] == '7'){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3696
N,T=map(int,input().split())
A=list(map(int,input().split()))
d=0
m=A[0]
M=A[0]
for i in range(N):
    if m>A[i]:
        m=A[i]
        M=A[i]
    elif M<A[i]:
        M=A[i]
        d=max(M-m,d)
tmp=0
D=0
m=A[0]
M=A[0]
for i in range(N):
    if m>A[i]:
        m=A[i]
        M=A[i]
    elif M<A[i]:
        M=A[i]
        D=max(M-m,D)
        if M-m==d:
            tmp+=1
print(tmp)


Measured memory_bytes: 62960
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int d[N];
  for(int i=0;i<N;++i) cin>>d[i];
  int ans = 0;
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      ans += d[i]*d[j];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long N;
  cin>>N;
  string s;
  char arr[26]={'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'};
  int x=0, y=0,count=0;
  while(true){
    if(N<26){
      
      break;
    }
    else{
      if(N%26!=0){
         N--;
        count++;
      }
      else if(N%26==0 && count==0){
        s+=arr[25];
        N-=1;
        N=N/26;
      }
      else{
        s+=arr[count-1];
        N=N/26;
        count=0;
      }
    }
  }
  if(N==26){
    s+=arr[0];
  }
  else if(N>=1&&N<26){
    s+=arr[N-1];
  }
  
reverse(s.begin(),s.end());
cout<<s;
  return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var dic = new SortedDictionary<string, int>(StringComparer.OrdinalIgnoreCase);

        var maxCount = 1;
        for (int i = 0; i < n; i++)
        {
            var word = Console.ReadLine();
            if (dic.ContainsKey(word))
            {
                dic[word]++;
                if (dic[word] > maxCount)
                {
                    maxCount = dic[word];
                }
            }
            else
            {
                dic.Add(word, 1);
            }
        }

        foreach (var s in dic.Where(x => x.Value == maxCount))
        {
            Console.WriteLine(s.Key);
        }
    }
}

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

ll N, M;
vector<vector<ll>> G;
vector<ll> colors;
//頂点vから辺をちょうど3本たどる
bool is_bipartite(ll v, ll color = 0) {
    colors[v] = color;
    for (auto nv : G[v]) {
        if (colors[nv] == color) return false;
        else if (colors[nv] == -1 && !(is_bipartite(nv, 1-color))) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N >> M;
    G.resize(N);
    colors.assign(N, -1);
    for (int i = 0; i < M; i++) {
        ll a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (is_bipartite(0)) {
        ll B, W = 0;
        for (int i = 0; i < N; i++) {
            W += colors[i];
        }
        B = N-W;
        cout << B*W-M << endl;
    }
    else cout << N*(N-1)/2-M << endl;
}

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

int main ()
{
  long int N, K, Q;
  cin >> N >> K >> Q;
  vector<long int> points;
  for (int i = 0; i < N; i++) points.push_back(0);

  int resta = Q-K;

  for (int i = 0; i < Q; i++)
  {
    int xi; cin >> xi; xi--;

    points[xi]++;
  }

  for (int i = 0; i < N; i++)
  {
    if (points[i] > resta) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1524
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

bool prime[1000000];
int ans[1000000];

void is_prime(){
  rep(i,1000000)prime[i]=true;
  prime[0]=prime[1]=false;
  REP(i,2,1000000){
    if(prime[i]==true){
      for(int j=i+i;j<1000000;j+=i)prime[j]=false;
    }
  }
  if(debug)rep(i,1000)if(prime[i])cout<<i<<endl;
}

void calc(){
  ans[0]=0;
  REP(i,1,1000000){
    ans[i]=ans[i-1]+prime[i];
  }
}

int main(){
  int n;
  is_prime();
  calc();
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  return 0;
}

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)

int main() {
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0) cout<<(a+b)/2;
  else cout<<"IMPOSSIBLE";
  return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>


long long int cal_time(const long long int time) {
	if (time <= 3) {
		return time;
	}
	else {
		switch (time % 3) {
		case 0: return cal_time((time - 2) / 3) + 3;
		case 1: return cal_time((time - 2) / 3) + 4;
		case 2: return cal_time((time - 2) / 3) + 2;
		default: throw 0;
		}
	}
}
int main() {
	long long int t; std::cin >> t;
	std::cout << cal_time(t + 1) - 1 << '\n';
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int countOIs(vector<vector<int> >& OI, string& strS, string& strT, int s, int t) {
    if(OI[s][t]!=0) return OI[s][t];
    int ans=0;
    if(strS[s]=='O' && strS[s+1]=='I') {
        OI[s+2][t]=countOIs(OI,strS,strT,s+2,t);
        ans=OI[s+2][t]+2;
    }
    if(strT[t]=='O' && strT[t+1]=='I') {
        OI[s][t+2]=countOIs(OI,strS,strT,s,t+2);
        ans=max(ans,OI[s][t+2]+2);
    }
    if((strS[s]=='O' && strT[t]=='I') || strS[s]=='I' && strT[t]=='O') {
        OI[s+1][t+1]=countOIs(OI,strS,strT,s+1,t+1);
        ans=max(ans,OI[s+1][t+1]+2);
    }
    return ans;
}

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

    string strS,strT;
    cin >> strS >> strT;

    strS+="EEE";
    strT+="EEE";

    vector<vector<int> > OI;
    vector<int> vtemp(N+3,0);

    for(int i=0; i<=M+2; ++i) {
        OI.push_back(vtemp);
    }

    for(int i=0; i<M; ++i) {
        for(int j=0; j<N; ++j) {
            OI[i][j]=countOIs(OI,strS,strT,i,j);
        }
    }

    int ans=0;
    for(int i=0; i<(int)strS.size(); ++i) {
        for(int j=0; j<(int)strT.size(); ++j) {
            if(strS[i]=='I') ans=max(ans,1+OI[i+1][j]);
            if(strT[j]=='I') ans=max(ans,1+OI[i][j+1]);
        }
    }   
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 19284
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

 
signed main(void){
    int N,M;
    int s[8],c[8];
    cin >> N >> M;
    REP(i,M){
        cin >> s[i] >> c[i];
    }
    
    for(int i=0;i<1000;i++){
        if(N==1 && !(0<=i && i<10)){
            continue;
        }
        if(N==2 && !(10<=i && i<100)){
            continue;
        }
        if(N==3 && !(100<=i && i<1000)){
            continue;
        }
        
        int kazu[3]={};
        int k=N-1;
        int l=i;
        while(k>=0){
            kazu[k]=l%10;
            l/=10;
            k--;
        }
        bool ok=true;
        REP(j,M){
            if(kazu[s[j]-1]!=c[j]){
                ok=false;
            }
        }
            //cout <<i MM  kazu[0] MM kazu[1] MM kazu[2] << endl;
        if(ok){
            cout << i << endl;
            return 0;
        }
        
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from itertools import permutations

    n, m = map(int, input().split())
    graph = [[0 for __ in range(n)] for _ in range(n)]
    ans = 0

    for i in range(m):
        ai, bi = map(lambda x: int(x) - 1, input().split())
        graph[ai][bi] = 1
        graph[bi][ai] = 1

    for j in list(permutations(range(n))):
        count = 0

        if j[0] == 0:
            for k in range(n - 1):
                _from = j[k]
                _to = j[k + 1]

                if graph[_from][_to] == 1:
                    count += 1

            if count == n - 1:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Tenka1
    {
        static void Main(string[] args)
        {
            string rawinput = Console.ReadLine();
            if (rawinput.Length == 3)
            {
                string ans = new string(rawinput.Reverse().ToArray());
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine(rawinput);
            }

        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
signed main(){
    int n;
    cin>>n;
    int o=n%10;
    if(o==3)puts("bon");
    else if(o==0||o==1||o==6||o==8)puts("pon");
    else puts("hon");
    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static long[] Solve(long K)
        {
            long N = (K + 49) / 50;
            long[] a = Enumerable.Repeat(N + 49, 50).ToArray();
            for (long i = N * 50; i > K; --i)
            {
                for (int j = 0; j < 49; ++j) { ++a[j]; }
                a[49] -= 50;
                Array.Sort(a);
            }
            return a;
        }
        static void Main(string[] args)
        {
            long K = long.Parse(Console.ReadLine());
            Console.WriteLine("50");
            Console.WriteLine(string.Join(" ", Solve(K)));
        }
    }
}


Measured memory_bytes: 13396
D,G=map(int,input().split())
problem=[]
compscore=[]
for i in range(0,D):
    p,c=map(int,input().split())
    problem.append(p)
    compscore.append(c)

def condition(num):
    for i in range(0,2**D):
        complete=set([])
        score=0
        solve=0
        for j in range(0,D):
            if i>>j &1 ==1:
                complete.add(j)
                score+=compscore[j]+100*(j+1)*problem[j]
                solve+=problem[j]

        if solve>num:
            continue
        else:
            x=num-solve
            full=set([i for i in range(0,D)])
            nokori=full-complete
            nokori=list(nokori)
            if not nokori:
                return score>=G
            else:
                m=max(nokori)
                if x>=problem[m]:
                    continue
                else:
                    score+=x*100*(m+1)
                    if score>=G:
                        return True

    return False

start=1
end=sum(problem)
while end-start>1:
    test=(end+start)//2
    if condition(test):
        end=test
    else:
        start=test

if condition(start):
    print(start)
else:
    print(end)

Measured memory_bytes: 45916
#define SUBMIT

// https://beta.atcoder.jp/contests/abc105

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int N, M;
#ifdef SUBMIT
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
#else
    N = 13, M = 17;
    vector<int> A {29, 7, 5, 7, 9, 51, 7, 13, 8, 55, 42, 9, 81};
//    N = 3, M = 2;
//    vector<int> A {4, 1, 5};
#endif
    map<ui64, ui64> mod_to_count;

    ui64 s = 0;
    mod_to_count[s % M]++;
    for (int i = 0; i < N; ++i) {
        s += A[i];
        mod_to_count[s % M]++;
    }

    ui64 ans = 0;
    for (const auto& p : mod_to_count) {
//        cout << "(" << p.first << ", " << p.second << ")" << endl;
        ans += p.second * (p.second - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
if(a[0]==5&&a[1]==5&&a[2]==7)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;

}


Measured memory_bytes: 256
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	ll a,b,v,w;
	cin >> a >> v >> b >> w;
	ll t;
	cin >> t;
	ll d = abs(b-a);
	ll p = v-w;
	if(d == 0){
		cout << "YES" <<endl;
	}else if(p <= 0){
		cout << "NO" << endl;
	}else if(d > t*p){
		cout << "NO" << endl;
	}else{
		cout << "YES"<<endl;
	}
	return 0;
}


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

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

    // S:= {(x,y)| 0 < y < (ax+b)/m && 0 <= x <= n)
    // floor_sum(n,m,a,b) = |S|

    int Q;
    cin >> Q;
    rep(q,Q) {
        ll n,m,a,b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3556
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  string S;
  int ac=0,wa=0,tle=0,re=0;
  rep(i,0,N){
    cin >> S;
    if(S=="AC") ac++;
    else if(S=="WA") wa++;
    else if(S=="TLE") tle++;
    else if(S=="RE") re++;
  }
  
  cout << "AC " << "x " << ac << '\n';
  cout << "WA " << "x " << wa << '\n';
  cout << "TLE " << "x " << tle << '\n';
  cout << "RE " << "x " << re << '\n';
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
#include <math.h>

#define max 100

int* sortMaxmin(int*, int);
int* sortMinmax(int*, int);

int main()
{
    int N, ans;
    
    scanf("%d", &N);
    
    ans=pow(N, 3);
    
    printf("%d", ans);

    return 0;
}

int* sortMaxmin(int *a, int b)
{
    int i, j, tmp;
    
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]>a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}

int* sortMinmax(int *a, int b)
{
    int i, j, tmp;
    
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]<a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		sc.close();

		System.out.println(t / a * b);
	}
}


Measured memory_bytes: 23380
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}

int l,r;

main(){
	cin>>l>>r;
	int flg=0;
	for(int i=l;;i++){
		if((i%2019)==0){
			flg=1;
			break;
		}
		if(i==r)break;
	}
	if(flg){
		dump(0);
		return 0;
	}
	int ans=INT_MAX;
	for(int i=l;i<=r-1;i++){
		for(int j=i+1;j<=r;j++){
			ans=min(ans,((i*j)%2019));
		}
	}
	dans;
}




Measured memory_bytes: 256
H, W = map(int, input().split())
MA = [list(input().strip()) for _ in range(H)]
VI = [[-1] * W for _ in range(H)]

kabe = 0
for i in range(H):
    kabe += MA[i].count("#")

from collections import deque


def bfs(ma, vi):
    Q = deque([(0,0)])
    sy, sx = (0,0)
    vi[sy][sx] = 0
    while True:
        if Q == deque([]):
            return -1
        q = Q.popleft()
        y, x = q
        if q == (H-1,W-1):
            return vi[y][x]
        for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)):
            nq = y + dy, x + dx
            ny, nx = nq
            if 0 <= ny < H and 0 <= nx < W and vi[ny][nx] == -1:
                if ma[ny][nx] == '.':
                    Q.append(nq)
                    vi[ny][nx] = vi[y][x] + 1


score = bfs(MA,VI)

if score != -1:
    print(H * W - kabe - score - 1)
else:
    print(-1)

Measured memory_bytes: 3316
#include<cstdio>
#define mod 1000000007
using namespace std;
int h,w;
long dp[1001][1001]={};
char s[1001][1001];
int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        scanf("%s",s[i]);
    }
    dp[1][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j];
                dp[i+1][j+1]%=mod;
            }
        }
    }
    printf("%d\n",dp[h][w]);
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define int long long
const int N = 2e5 + 5;
using namespace std;

int n, k, p[N], bit[N];
long long a[N], ans;

void update(int i){
    while (i < N){
        bit[i]++;
        i += i&(-i);
    }
}

int get(int i){
    int ans = 0;
    while (i > 0){
        ans += bit[i];
        i -= i&(-i);
    }
    return ans;
}

signed main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) a[i] += a[i-1] - k;
    for (int i = 0; i <= n; i++) p[i] = i;
    sort(p, p+1+n, [](int x, int y){return (a[x] < a[y] || (a[x] == a[y] && x < y));});
    for (int i = 0; i <= n; i++) a[p[i]] = i+1;
    update(a[0]);
    for (int i = 1; i <= n; i++){
        ans += get(a[i]);
        update(a[i]);
    }
    cout << ans;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t n;
	cin >> n;
	int odd = 0;
	int even = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0)even++;
		else odd++;
	}
	if (odd == 0||odd%2==0||odd+even==1) {
		cout << "YES" << endl;
	}
	else  {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  string ans[]={
    "AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR",
    "KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR",
    "AKIHBR","KIHABR","KIHBAR","KIHBRA","KIHBR"
  };
  REP(i, 16){
    if(s == ans[i]){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
  return 0;
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


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


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

    ll m = 0, a = 0, r = 0, c = 0, h = 0;
    int n;
    cin >> n;
    rep(i, 0, n) {
        string s;
        cin >> s;
        switch (s[0]) {
            case 'M':
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C':
                c++;
                break;
            case 'H':
                h++;
                break;
            default:
                break;
        }
    }
    ll arr[5] = {m, a, r, c, h};
    ll ans = 0;
    rep(i, 0, 1 << 5) {
        int bitc = 0;
        ll tmp = 1;
        for (int j = 0; j < 5; j++) {
            if (i >> j & 1) {
                bitc++;
                tmp *= arr[j];
            }
        }
        if (bitc == 3) {
            ans += tmp;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 888
# coding: utf-8

while True:
	n, m = map(int, raw_input().split())
	if n == 0:
		break
	else:
		data = []
		for i in range(n):
			student = map(int, raw_input().split())
			data.append(student)
		result = []
		for j in range(m):
			sum = 0
			for i in range(n):
				sum += data[i][j]
			result.append(sum)
#		print result

		ans = []
		for i in range(1,m+1):
			ans.append(i)
		for i in range(1,m): #(0,1),,,,(m-2,m-1)
			for j in range(1,m-i+1):
				if result[j-1] < result[j]:
					tmp = ans[j-1]
					ans[j-1] = ans[j]
					ans[j] = tmp
					tmp = result[j-1]
					result[j-1] = result[j]
					result[j] = tmp
#				print j-1, j
#				print ans
#				print result
		ans_text = ""
		for i in range(m-1):
			ans_text += str(ans[i]) + " "
		ans_text += str(ans[m-1])
		print(ans_text)

Measured memory_bytes: 5396
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int W, H;
char fld[80][80];

string bigger(string s, string t) {
    int lens = s.size();
    int lent = t.size();
    if (lens < lent) {
        return t;
    } else if (lens > lent) {
        return s;
    } else {
        for (int i = 0; i < lens; i++) {
            char ss = s[i];
            char tt = t[i];
            if (ss < tt) {
                return t;
            } else if (ss > tt) {
                return s;
            }
        }
        return t;
    }
}

string dp[80][80];

void solve(int W, int H) {
    for (int i = 0; i < H + 10; i++) {
        fill(dp[i], dp[i] + W + 10, "");
    }
    for (int i = H - 1; i >= 0; i--) {
        for (int j = W - 1; j >= 0; j--) {
            if (fld[i][j] != 'X') {
                string s[2] = {"", ""};
                for (int k = 0; k < 2; k++) {
                    if (i + dx[k] < H && j + dy[k] < W) {
                        if (fld[i + dx[k]][j + dy[k]] != 'X') {
                            s[k] = dp[i + dx[k]][j + dy[k]];
                        }
                    }
                }
                dp[i][j] = fld[i][j] + bigger(s[0], s[1]);
            }
        }
    }
    string ans = "";
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (fld[i][j] != 'X' && fld[i][j] != '0') {
                ans = bigger(ans, dp[i][j]);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    while (1) {
        cin >> W >> H;
        if (W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            string s;
            cin >> s;
            for (int j = 0; j < W; j++) {
                if (s[j] >= '0' && s[j] <= '9') {
                    fld[i][j] = s[j];
                } else {
                    fld[i][j] = 'X';
                }
            }
        }
        solve(W, H);
    }
}



Measured memory_bytes: 3336
h, w = [int(i) for i in input().split()]
s = [input() for j in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        f = False
        if j > 0:
            if s[i][j-1] == "#":
                f = True
        if j < w-1:
            if s[i][j+1] == "#":
                f = True
        if i > 0:
            if s[i-1][j] == "#":
                f = True
        if i < h-1:
            if s[i+1][j] == "#":
                f = True
        if not f:
            print("No")
            exit()
print("Yes")

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int x, y;
    cin >> x >> y;
    if(y % 2) {
        cout << "No\n"; 
    } else {
        int mn = x * 2;
        int mx = x * 4;
        if(y >= mn && y <= mx) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
	int A,B;
 	int max;
	scanf("%d %d",&A,&B);
	int wa=A+B;
	int sa=A-B;
	int seki=A*B;
	if(wa<=seki&&sa<=seki){
		max=seki;
    }else if(wa<=sa&&seki<=sa){
		max=sa;
    }else{
    	max=wa;
    }
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string A, B;
  cin >> A >> B;
  if (A.size() < B.size()) {
    cout << "LESS" << endl;
    return 0;
  } else if (A.size() > B.size()) {
    cout << "GREATER" << endl;
    return 0;
  }

  REP(i, 0, A.size()) {
    if (A[i] < B[i]) {
      cout << "LESS" << endl;
      return 0;
    } else if (A[i] > B[i]) {
      cout << "GREATER" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
  return 0;
}


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

int main(){    
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a == 0) cout << 1 << endl;
  if(b == 0) cout << 2 << endl;
  if(c == 0) cout << 3 << endl;
  if(d == 0) cout << 4 << endl;
  if(e == 0) cout << 5 << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

ll com[51][51];

int main(){
  com[0][0] = 1;
  for (int i = 1; i < 51; i++){
    for(int j = 0; j <= i; j++){
      com[i][j] += com[i-1][j];
      if(j>0) com[i][j] += com[i-1][j-1];
    }
  }
  
  int n,a,b; cin >> n >> a >> b;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end(),greater<ll>());
  
  ll sum = 0;
  rep(i,a) sum += v[i];
  double ave = (double)sum/a;
  printf("%.10f\n",ave);
  
  //一番小さい数の数。
  int cnt = 0;
  //場合の数（答え）
  ll ans = 0;
  rep(i,n){
    if(v[i]==v[a-1]) cnt++;
  }
  
  if(v[0]==v[a-1]){
    for(int i = a; i <= b; i++){
      ans += com[cnt][i];
    }
  }else{
    int cnt_inA = 0;
    rep(i,a) if(v[i] == v[a-1]) cnt_inA++;
    ans += com[cnt][cnt_inA];
  }
  
  // 計算例
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define t ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
  fast;
  ll n;
  cin>>n;
  ll a[n];
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  ll ans = 0;
  for(int i=1; i<n;i++){
    if(a[i]<a[i-1]){
        ans+=(a[i-1]-a[i]);
        a[i]=a[i-1];
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
#define INF 1e9
#define int long long
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    rep(i, 26)
    {
        char c = 'a' + i;
        vector<int> v(s.size());
        rep(j, s.size())
        {
            if (s[j] == c)
                v[j] = 1;
            else
                v[j] = -1;
        }
        vector<int> sum(s.size() + 1);
        sum[0] = 0;
        rep(j, s.size()) sum[j + 1] = sum[j] + v[j];
        vector<int> Max(s.size() + 1);
        Max[s.size()] = sum[s.size()];
        repr(j, s.size() - 1) Max[j] = max(Max[j + 1], sum[j]);
        rep(j, s.size() - 1)
        {
            if (Max[j + 2] - sum[j] > 0)
            {
                cout << j + 1 << " ";
                int cnt = v[j];
                Rep(k, s.size(), j + 1)
                {
                    cnt += v[k];
                    if (cnt > 0)
                    {
                        cout << k + 1 << endl;
                        break;
                    }
                }
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 2896