akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    

    class Program
    {
        
        //41bitの2進数(左に上位bit)を返す
        static string GetBinary(long n)
        {
            string binary = "";

            //下位bitから埋めていく
            int next_bit = 0;
            while (true)
            {
                long amari = n % 2;
                binary = amari.ToString() + binary;
                n /= 2;
                next_bit++;
                if (n == 0) break;
            }

            //残りのbitを0で埋める
            for(int i = next_bit; i <= 41; i++)
            {
                binary = "0" + binary;
            }

            return binary;
        }

        //string2進数を10進数にして返す
        static long GetDecimal(string binary)
        {
            //右を上位bitへ
            binary = string.Join("", binary.Reverse());
            
            long rec = 0;

            //i bit目
            for(int i = 0; i < binary.Length; i++)
            {
                if(binary[i] == '1') rec += (long)Math.Pow(2, i);
            }

            return rec;
        }

        //aとbのXORを10進数で返す
        static long XOR(long a, long b)
        {
            //左が上位bit
            string a_binary = GetBinary(a);
            string b_binary = GetBinary(b);
            
            int bit = a_binary.Length - 1;
            
            //各bitでXOR実行
            string xor = "";
            for(int i = 0; i <= bit; i++)
            {
                if(a_binary[i] != b_binary[i])
                {
                    xor += "1";
                }
                else
                {
                    xor += "0";
                }
            }

            //10進数にして返す
            return GetDecimal(xor);
        }

        //0～Aまでの排他的論理和を10進数で返す
        static long F(long A)
        {
            
            //cnt = (遇, 奇)のペアの数 = XORした時の1の個数          
            long cnt = 0;
            if (A % 2 == 1) cnt = (A + 1) / 2;
            else cnt = A / 2;

            //cntが奇数なら1が残る
            long s = 0;
            if (cnt % 2 == 1) s = 1;
            
            if(A % 2 == 0)
            {
                s = XOR(s, A);
            }

            return s;
        }


        static long Solve(long A, long B)
        {
            return XOR(F(A - 1), F(B));
        }

        static void Main(string[] args)
        {
            //A, Bの入力
            string[] input = Console.ReadLine().Split(' ');
            long A = long.Parse(input[0]);
            long B = long.Parse(input[1]);

                      
            //n XOR n = 0と、
            //偶数nについて
            //n XOR (n + 1) = 1
            //という2つの性質を使って解く

            Console.WriteLine(Solve(A, B));
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 1;
    ll t = 0;
    for (ll k = 2; k * k <= n; k++) {
        t = k;
        ll t = 1;
        for (;;) {
            if (n % (t * k) == t) {
                //cout << k << endl;
                r++;
                break;
            }
            t *= k;
            if (t > n) break;
        }
    }

    ll m = n - 1;
    for (ll l = 2; l * l <= n; l++) {
        ll k = m / l;
        if (m % l == 0 && k > t) {
            //cout << m / k << endl;
            r++;
        }
    }
    if (n > 2) r++;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int a[1111];
	int min=INF,ans=0,ke;
	rep(i,5){
		cin>>a[i];
		if(a[i]%10<min && a[i]%10!=0){
			min=a[i]%10;
			ke=a[i];
		}
		if(a[i]%10!=0)ans+=(a[i]/10)*10+10;
		else ans+=a[i];//cout<<ans<<endl;
	}
	if(ke%10!=0)ans-=(ke/10)*10+10;
	else ans-=ke;//cout<<ans<<endl;
	
	cout<<ans+ke<<endl;
}

Measured memory_bytes: 256
import random


d=int(input())
C=[int(i) for i in input().split()]
s=[[int(i) for i in input().split()] for q in range(d)]

sco=0
L=[0 for i in range(26)]
ans=[]

#calc
for i in range(d):
    mayou=0
    est=s[i][0]+C[0]*(i+1-L[0])
    for p in range(1,26):
        if s[i][p]+C[p]*(i+1-L[p]) > est:
            mayou=p
            est=s[i][p]+C[p]*(i+1-L[p])
    ans.append(mayou)
    L[mayou]=i+1


sco=est

##以下表示
"""
L=[0 for i in range(26)]
for q in range(d):
    t=ans[q]
    sco+=s[q][t]
    
    
    L[t]=q+1
    for i in range(26):
        if L[i]!=-1:
            sco-=C[i]*(q+1-L[i])
    
    print(sco)
"""


m=1000000

for que in range(m):
    newsco=sco
    dn,q=random.choice(range(1,d)),random.choice(range(1,27))
    dn-=1
    q-=1
    old=ans[dn]
    ans[dn]=q
    now=dn
    cnt=1
    while now!=0 and ans[now]!=old:
        now-=1
        cnt+=1
    now=dn
    while now!=d and ans[now]!=old:
        newsco-=cnt*C[old]
        now+=1
        cnt+=1
    newsco-=s[dn][old]
    newsco+=s[dn][q]
    now=dn
    cnt=1
    while now!=0 and ans[now]!=q:
        now-=1
        cnt+=1
    now=dn
    while now!=d and ans[now]!=q:
        newsco+=cnt*C[q]
        now+=1
        cnt+=1
    #print(newsco)
    if newsco>sco:
        sco=newsco
        #print(newsco)
    else:
        ans[dn]=old

for ele in ans:
    print(ele+1)
    


Measured memory_bytes: 86156
s = input().split()
n = int(s[0])
k = int(s[1])
total = 0
for i in range(1, n+1):
  tmp = i
  cnt = 0
  while(tmp < k):
    tmp *= 2
    cnt += 1
  total += 0.5 ** cnt
print(total / n)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

int ans = 0;
list<int> *adj;
vi h(100001);

void dfs(bool vis[], int v){
	vis[v]=1;
	bool f = 1;
	for(auto i:adj[v]){
		if(!vis[i]){
			dfs(vis,i);
		}
		if(h[v]<=h[i]){
			f=0;
		}
	}
	if(f){
		ans++;
	}
}

void solve(){
    int n,m,u,v; cin>>n>>m;
    adj = new list<int>[n];
    for(int i = 0; i < n; ++i){
    	cin>>h[i];
    }
    for(int i = 0; i < m; ++i){
    	cin>>u>>v;
    	--u,--v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    bool vis[n];
    clr(vis);
    for(int i = 0; i < n; ++i){
    	if(!vis[i]){
    		dfs(vis,i);
    	}
    }
    cout<<ans<<'\n';
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

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

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
    }
    else
    {
        cout<<(n/x+1)*t;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct State{
	int y,x,dir;
};

void Solve(){
	while(true){
		ll h,w,l;
		cin >> h >> w >> l;
		if(h==0&&w==0&&l==0) break;
		vector<string> cells(h);
		REP(i,0,h) cin >> cells[i];

		const char empty='.',wall='#';
		const int north=0,east=1,south=2,west=3;
		int y,x,dir;
		REP(i,0,h) REP(j,0,w) if(cells[i][j]!=empty&&cells[i][j]!=wall){
			y=i; x=j;
			switch(cells[i][j]){
				case 'N': dir=north; break;
				case 'E': dir=east; break;
				case 'S': dir=south; break;
				case 'W': dir=west; break;
				default: break;
			}
			cells[i][j]=empty;
			break;
		}

		int rotate[4];
		REP(i,0,4) rotate[i]=(i+1)%4;

		//State memo[100][100][4];
		//REP(i,0,h) REP(j,0,w) REP(k,0,4){
			//int y_=i,x_=j;
			//int ny=y_+dy[k],nx=x_+dx[k];
			//while(0<=ny&&ny<h&&0<=nx&&nx<w&&cells[ny][nx]==empty){
				//y_=ny; x_=nx;
				//ny=y_+dy[k]; nx=x_+dx[k];
			//}
			//memo[i][j][k]={y_,x_,rotate[k]};
		//}

		const int dx[]={0,1,0,-1},dy[]={-1,0,1,0};
		ll visited[100][100][4];
		fill_n((ll*)visited,100*100*4,-1);
		ll cnt=0;
		while(cnt<l){
			dump(y);
			dump(x);
			if(visited[y][x][dir]==-1) visited[y][x][dir]=cnt;
			else{
				cnt+=((l-cnt)/(cnt-visited[y][x][dir]))*(cnt-visited[y][x][dir]);
				if(cnt==l) break;
			}
			
			int ny=y+dy[dir],nx=x+dx[dir];
			while(!(0<=ny&&ny<h&&0<=nx&&nx<w&&cells[ny][nx]==empty)){
				dir=rotate[dir];
				ny=y+dy[dir]; nx=x+dx[dir];
			}
			y=ny; x=nx; ++cnt;
		}

		cout << y+1 << ' ' << x+1 << ' ' << "NESW"[dir] << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
struct edge{
	int u,v,w;
}e[2005];
int d[2005];
int inf=100000000;
int f[2005];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
void join(int x,int y){
	int fx=find(x);
	int fy=find(y);
	if(fx==fy)return;
	f[fx]=fy;
}
int main(){
	int n,m,s,u,v,w;cin>>n>>m>>s;
	for(int i=0;i<m;i++)cin>>u>>v>>w,e[i]={u,v,w};
	for(int i=0;i<=n;i++)d[i]=inf,f[i]=i;
	bool ok=1;d[s]=0;
	for(int i=0;i<n;i++){
		bool change=0;
		for(int j=0;j<m;j++)
			if(d[e[j].u]+e[j].w<d[e[j].v])
				d[e[j].v]=d[e[j].u]+e[j].w,change=1,join(e[j].v,e[j].u);
	}
	for(int j=0;j<m;j++)
		if(d[e[j].u]+e[j].w<d[e[j].v])
			if(find(e[j].u)==find(s))ok=0;
	if(!ok){cout<<"NEGATIVE CYCLE"<<endl;return 0;}
	for(int i=0;i<n;i++)if(find(i)!=find(s)||d[i]>=inf-1000*10000)cout<<"INF"<<endl;else cout<<d[i]<<endl;
	return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL R, G, B, N;
	cin >> R >> G >> B >> N;
	LL r, g, b;
	LL ans = 0;
	for(r=0; r<=3000; r++){
		for(b=0; b<=3000; b++){
			LL v = N - (R*r) - (B*b);
			if(v >= 0 && (v % G) == 0){
				ans++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3772
sx, sy, tx, ty = [int(_) for _ in input().split()]

ans = ''
for i in range(0, tx-sx):
    ans += 'R'
for i in range(0, ty-sy):
    ans += 'U'
for i in range(0, tx-sx):
    ans += 'L'
for i in range(0, ty-sy):
    ans += 'D'
ans += 'D'
for i in range(0, tx-sx+1):
    ans += 'R'
for i in range(0, ty-sy+1):
    ans += 'U'
ans += 'LU'
for i in range(0, tx-sx+1):
    ans += 'L'
for i in range(0, ty-sy+1):
    ans += 'D'
ans += 'R'
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		int sai[7]={0};
		reps(i,6)sai[i]=i;
		
		int ans=1;
		rep(i,n){
			string a;
			cin>>a;
			int tm;
			if(a[0] == 'N'){
				tm=sai[1];
				sai[1]=sai[2];
				sai[2]=sai[6];
				sai[6]=sai[5];
				sai[5]=tm;
			}
			if(a[0] == 'S'){
				tm=sai[1];
				sai[1]=sai[5];
				sai[5]=sai[6];
				sai[6]=sai[2];
				sai[2]=tm;
			}
			if(a[0] == 'E'){
				tm=sai[1];
				sai[1]=sai[4];
				sai[4]=sai[6];
				sai[6]=sai[3];
				sai[3]=tm;
			}
			if(a[0] == 'W'){
				tm=sai[1];
				sai[1]=sai[3];
				sai[3]=sai[6];
				sai[6]=sai[4];
				sai[4]=tm;
			}
			if(a[0] == 'L'){
				tm=sai[2];
				sai[2]=sai[4];
				sai[4]=sai[5];
				sai[5]=sai[3];
				sai[3]=tm;
			}
			if(a[0] == 'R'){
				tm=sai[2];
				sai[2]=sai[3];
				sai[3]=sai[5];
				sai[5]=sai[4];
				sai[4]=tm;
			}
			ans+=sai[1];
		}
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int a = in.nextInt(), b = in.nextInt();
		int c = in.nextInt(), d = in.nextInt();
		int p = in.nextInt();

		int x = a * p;
		int y;
		if(p <= c) y = b;
		else y = b + (p - c) * d;

		System.out.println(Math.min(x,y));
	}

}

Measured memory_bytes: 26336
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].F >> a[i].S;
    a[i] = {a[i].F + a[i].S, 2 * a[i].S};
  }
  sort(all(a));
  vector<int> dp(n + 1), mx(n + 1);
  dp[0] = 0;
  int inf = int(2e9) + 7;
  for (int i = 1; i <= n; i++) {
    int pos = upper_bound(all(a), make_pair(a[i - 1].F - a[i - 1].S, inf)) - a.begin();
    dp[i] = mx[pos] + 1;
    mx[i] = max(mx[i - 1], dp[i]);
  }
  cout << mx[n] << '\n';
} 

Measured memory_bytes: 6320
PROGRAM someSums
      IMPLICIT NONE
      INTEGER :: N,A,B, ans
      INTEGER :: num(5), digit, i, piyo, aa,bb,cc,dd,ee , s
      
      READ*,N,A,B
      ans = 0
      
      num(:) = 0
      digit = 10000
      piyo = N
      DO i = 1,5
        DO while(.TRUE.)
          IF(piyo>=digit)THEN
            piyo = piyo - digit
            num(i) = num(i) + 1
          ELSE
            digit = digit / 10
            EXIT
          END IF
        END DO
      END DO
      
      alldo:DO aa = 0,9
        DO bb = 0,9
          DO cc = 0,9
            DO dd = 0,9
              DO ee = 0,9
                s = aa + bb + cc + dd + ee
                IF(A<=s.AND.B>=s)THEN
                  ans = ans + aa*10000+bb*1000+cc*100+dd*10+ee
                END IF
                IF(ee==num(5).AND.dd==num(4).AND.cc==num(3).AND. &
                  bb==num(2).AND.aa==num(1))THEN
                  EXIT alldo
                END IF
              END DO
            END DO
          END DO
        END DO
      END DO alldo
      
      print'(I0)',ans
      
      
      
      END PROGRAM

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(int argc, const char *argv[]){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) co(s);
    else co("red");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if((2*a*b)>=(c*c+a*a+b*b-2*c*(a+b))||(c-a-b)<=0)cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
typedef double ld;
typedef pair<int,int> p2;
typedef pair<p2,int> p3;
typedef vector<ll> vi;
const ll Mod = 7 + 1e9;
const ll INF32 = 5 + 2e9;
const ll INF64 = 5 + 1e18;
const ll MAX = 5+ 3e5;
int n,a[MAX],k;
int dp[MAX];
int main()
{
    cin >> n >> k ;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    fill(dp,dp+n+1,INF32);
    dp[1] = 0;
    for(int i=2;i<=n;i++)
        for(int j=1;j<=min(i-1,k);j++)
        dp[i] = min( dp[i],dp[i-j] + abs( a[i] - a[i-j] ) );
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	int n; cin >> n;
	n = (n - 2) * 180;
	cout << n;
	return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const vector<LLONG> Comp(const LLONG n)
{
	vector<LLONG> ret(n, 0);
	for (LLONG x = 1; x * x < n; ++x)
	{
		for (LLONG y = 1; x * x + y * y < n; ++y)
		{
			for (LLONG z = 1; x * x + y * y + z * z < n; ++z)
			{
				LLONG val = x * x + y * y + z * z + x * y + y * z + z * x;
				if (val <= n)
				{
					++ret[val- 1];
				}
			}
		}
	}
	return ret;
}

int main()
{
	LLONG N; cin >> N; 
	auto ans = Comp(N);
	for (auto i : ans)
	{
		cout << i << endl;
	}
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
#define MAX(a,b,c) max(a,max(b,c))
#define FOR(i,s,e) for(int i=s; i<=e; i++)
int cost[MAXN][4], memo[MAXN][2][2][2][4];
int n;
class fastio {
public:
    fastio() {
        ios_base::sync_with_stdio(false);
        cout.tie(nullptr);
        cin.tie(nullptr);
    }
} __fastio;
int f(int i, int ka, int kb, int kc, int phase) {
    if(i > n) return 0;
    if(memo[i][ka][kb][kc][phase] != -1) return memo[i][ka][kb][kc][phase];
    if(ka == 1) {
        if(kb > kc) return memo[i][ka][kb][kc][phase] = f(i+1, 0, 1, 0, 1) + cost[i][1];
        else if(kc > kb) return memo[i][ka][kb][kc][phase] = f(i+1, 0, 0, 1, 1) + cost[i][1];
        else return memo[i][ka][kb][kc][phase] = max(f(i+1, 0, 1, 0, 1) + cost[i][1], f(i+1, 0, 0, 1, 1) + cost[i][1]);
    }
    if(kb == 1) {
        if(ka > kc) return memo[i][ka][kb][kc][phase] = f(i+1, 1, 0, 0, 2) + cost[i][2];
        else if(kc > ka) memo[i][ka][kb][kc][phase] = f(i+1, 0, 0, 1, 2) + cost[i][2];
        else return memo[i][ka][kb][kc][phase] = max(f(i+1, 1, 0, 0, 2) + cost[i][2], f(i+1, 0, 0, 1, 2) + cost[i][2]);
    }
    if(kc == 1) {
        if(ka > kb) return memo[i][ka][kb][kc][phase] = (i+1, 1, 0, 0, 3) + cost[i][3];
        else if(kb > ka) return memo[i][ka][kb][kc][phase] = f(i+1, 0, 1, 0, 3) + cost[i][3];
        else return memo[i][ka][kb][kc][phase] = max(f(i+1, 1, 0, 0, 3) + cost[i][3], f(i+1, 0, 1, 0, 3) + cost[i][3]);
    }
}
void solve() {
    cin >> n;
    FOR(i,1,n) {
        cin >> cost[i][1] >> cost[i][2] >> cost[i][3];
    }
    memset(memo, -1, sizeof(memo));
    cout << MAX(f(1,1,0,0,1), f(1,0,1,0,2), f(1,0,0,1,3)) << endl;
}
int main() {
  __fastio;
  solve();
  return 0;
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    int sum=0,sum1=0;
    for(int i=n-1;i>0;i--)
    {
       sum=sum+i;
    }
    for(int i=m-1;i>0;i--)
    {
        sum1=sum1+i;
    }
    cout<<sum1+sum<<endl;


  return 0;
}





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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  vector<bool> good(n,true);
  rep(i,n) cin >> h[i];
  rep(i,m){
    int a,b;
    cin >> a >> b;
    if(h[a-1] >= h[b-1]) good[b-1] = false;
    if(h[a-1] <= h[b-1]) good[a-1] = false;
  }
  int count = 0;
  rep(i,n) count += good[i];
  cout << count << endl;
}



Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
set<ll> st;

int n;
void dfs(ll t, int u, int d){
	if(d == n){
		st.insert(t);
		return;
	}

	if(d == 0){
		for(int i = 1; i <= 9; i++){
			dfs(t * 10 + i, i, d + 1);
		}
	}else{
		if(u == 0){
			dfs(t * 10, 0, d + 1);
			dfs(t * 10 + 1, 1, d + 1);
		}else if(u == 9){
			dfs(t * 10 + 8, 8, d + 1);
			dfs(t * 10 + 9, 9, d + 1);
		}else{
			dfs(t * 10 + u - 1, u - 1, d + 1);
			dfs(t * 10 + u, u, d + 1);
			dfs(t * 10 + u + 1, u + 1, d + 1);
		}
	}
}

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

	ll k;
	cin >> k;

	for(int i = 1; i <= 10; i++){
		n = i;
		dfs(0, 0, 0);
	}

	auto itr = st.begin();
	rep(i, k - 1) itr++;
	cout << *itr << endl;
}


Measured memory_bytes: 9600
/* ex3_4
   tamayama　*/

#include<stdio.h>
 int main (void){
     int N;
     int i;
     int a=0;
     scanf("%d",&N);

     for(i=1; i<10; i++){
         if(N/i < 10 && N%i == 0){
             a++;
         }
     }

     if(a > 0){
         printf("Yes");
     }else{
         printf("No");
     }
     return 0;
 }

Measured memory_bytes: 128
#atcoder beginner contest 141

participant, point, correct = map(int, input("").split(" "))
indi_point = []

for i in range(participant):
    indi_point.append(0)

for i in range(correct):
    s_per = int(input(""))
    indi_point[s_per - 1] += 1

for i in range(participant):
    if point > correct - indi_point[i]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4672
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        boolean trueCount = false;
        for(int i = A; i<=B; i++){
            if(i % K == 0){
                trueCount = true;
            }
        }
        System.out.println(trueCount == true ? "OK" : "NG");
    }
}

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

string str;
int n, vet[100009];
int main(){
	char mapa[] = {'A','S','W'};
	cin >> n >> str;
	for(int i1 = 1;i1<=2;i1++){
		bool f;
		for(int j1 = 1;j1<=2;j1++){
			vet[0] = i1;
			vet[1] = j1;
				
			for(int k = 1;k<n-1;k++){
				if(vet[k] == 1){
					if(str[k] == 'o')
						vet[k+1] = vet[k-1];
						
					else if(str[k] == 'x')
						vet[k+1] = 3-vet[k-1];
					
				}else{
					if(str[k] == 'x')
						vet[k+1] = vet[k-1];
					else
						vet[k+1] = 3-vet[k-1];
					
					}	
				}
			
			
			f = 1;
			for(int i =0;i<n;i++){
				if(vet[i] == 1){
					if(str[i] == 'o')
						f = f and (vet[(i-1+n)%n] == vet[(i+1)%n]);
					else
						f = f and (vet[(i-1+n)%n] != vet[(i+1)%n]);
			
			
				}else{
					if(str[i] == 'o')
						f = f and (vet[(i-1+n)%n] != vet[(i+1)%n]);	
					else
						f = f and (vet[(i-1+n)%n] == vet[(i+1)%n]);
							
					
				}
			}
			if(f){
				for(int i =0;i<n;i++) cout<<mapa[vet[i]];
				return 0;
			
			}
			
		}
	}
	
	cout<<-1;
}

Measured memory_bytes: 896
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

count = 0
pa = 0
for i in range(H):
    for j in range(W):
        a = S[i][j]
        if a == '#':
            if j-1 >= 0 and S[i][j-1] == '#':
                count += 1
            if j+1 <= W-1 and S[i][j+1] == '#':
                count += 1
            if i-1 >= 0 and S[i-1][j] == '#':
                count += 1
            if i+1 <= H-1 and S[i+1][j] == '#':
                count += 1

            if count >= 1:
                continue
            else:
                pa += 1
                break
        count = 0
if pa != 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> S;
    ll foundA = 0;
    ll foundZ = 0;
    fi(i, 0, S.size(), 1) {
    	if(S[i] == 'A') {
    		foundA = i;
    		break;
    	}
    }
    fi(i, 0, S.size(), 1) {
    	if(S[i] == 'Z') {
    		foundZ = i;
    		// break;
    	}
    }
    cout << foundZ - foundA + 1;
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,m,x; cin >> n >> m >> x;
    int count1=0,count2=0;
    rep(i,m){
        int a; cin >> a;
        if(a>x) count1 += 1;
        else count2 += 1;
    }
    cout << min(count1,count2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;




class UnionFind{
public:
    int uf[200005];
    UnionFind(){
        memset(uf,-1,sizeof uf);
    }
    
    int parent(int i){
        if (uf[i] < 0) return i;
        return uf[i] = parent(uf[i]);
    }
    
    void join(int i, int j){
        int pi = parent(i);
        int pj = parent(j);
        if (pi == pj) return;
        if (size(pi) < size(pj)) swap(pi,pj);
        uf[pi] += uf[pj];
        uf[pj] = pi;
        
    }
    
    int size(int i){
        int pi = parent(i);
        return abs(uf[pi]);
    }
    
    void init(){
        memset(uf,-1,sizeof uf);
    }
};





void solve(){
    int n,m;
    cin >> n >> m;
    UnionFind uf = UnionFind();
    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        uf.join(a,b);
    }
    
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans,uf.size(i));
    }
    
    cout << ans;
};



int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 4412
from collections import deque


def solve():
    S = deque(list(input()))
    Q = int(input())
    state = 0
    for _ in range(Q):
        query = list(input().split())
        if int(query[0]) == 1:
            state = 1 if state == 0 else 0
        else:
            if (state + int(query[1])) % 2 == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
    if state == 0:
        print(''.join(S))
    else:
        S.reverse()
        print(''.join(S))


if __name__ == '__main__':
    solve()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int K; cin >> K;
    ll ans = 0;
    FOR(a,1,K+1){
        FOR(b,1,K+1){
            FOR(c,1,K+1){
                ans += __gcd(__gcd(a,b),c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a[100005];
int main(void){
    int n,k;cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=1;n-=k;
    while(n>0){
        n-=(k-1);
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            int[] B = new int[N];
            for (var i = 0; i < N-1; i++)
            {
                B[i] = int.Parse(input[i]);
            }
            A[0] = 1000000;
            for (var i = 0; i < N - 1; i++)
            {
                A[i] = Math.Min(A[i], B[i]);
                A[i+1] = B[i];
            }
            int ans = 0;
            for (var i = 0; i < N; i++)
            {
                ans += A[i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
 
def solve(N, K, D):
    i = 0
    while(True):
        test = N + i
        test_str = str(test)
        
        for j in range(K):
            index = -1
            index = test_str.find(D[j])
            if(index>=0):
                break
        if(index == -1):
            break
        i += 1
    print(test)
    
if __name__ == '__main__':
    N, K = map(int, input().split())
    D = [str(d) for d in input().split()]
    
    solve(N, K, D)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
#define MAXN 100001
lli N;
vector<pair<lli, lli>> graph[MAXN];

void dfs(lli cur, lli id, vector<lli> &flg)
{
    flg[cur] = id;
    REP(i, (lli)graph[cur].size())
    {
        lli point = graph[cur][i].first;
        lli weight = graph[cur][i].second;
        if (flg[point] == 0)
        {
            dfs(point, id * (-(weight % 2 == 1) * 2 + 1), flg);
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;

    REPS(i, N - 1)
    {
        lli x, y, z;
        cin >> x >> y >> z;
        graph[x].emplace_back(y, z);
        graph[y].emplace_back(x, z);
    }

    vector<lli> connectComponent(N + 1, 0);
    lli count = 0;
    /* connectComponent[1] = 1;
    dfs(1, 1, connectComponent);
    REPS(i, N)
    {
        cout << connectComponent[i] << "\n";
    }
    */
    REPS(i, N)
    {
        if (connectComponent[i] == 0)
        {
            //            connectComponent[i] = 1;
            dfs(i, 1, connectComponent);
            count++;
        }
    }
    REPS(i, N)
    {
        cout << ((connectComponent[i] > 0) ? 1 : 0) << "\n";
    }

    // cout << count << "\n";
}

Measured memory_bytes: 10240
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
using namespace std;

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;

static const int dx[4] = {-1, 0, 1, 0}; //??£??\???{}
static const int dy[4] = {0, -1, 0, 1};
static const int dir[4] = {'u', 'l', 'd', 'r'};

int MDT[N2][N2]; //???????????????????????¢

struct Puzzle {
	int p[N2], space, MD;
	string path;

	bool operator < (const Puzzle &p1) const { //????????§?????????
		for (int i = 0; i < N2; i++) {
			if (p[i] == p1.p[i]) continue;
			return p[i] > p1.p[i];
		}
		return false;
	}
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
	int sum = 0;
	for (int i = 0; i < N2; i++) {
		if (pz.p[i] == N2) continue;
		sum += MDT[i][pz.p[i] - 1]; //i????????¨????????????j???????????????
	}
	return sum;
}

bool dfs(int depth, int prev) {
	if (state.MD == 0) return true;
	if (depth + state.MD > limit) return false;
	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;

	for (int r = 0; r < 4; r++) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
		if (max(prev, r) - min(prev, r) == 2) continue; //??¢?´¢???????????£??????????????????????????????prev
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.p[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.p[tx * N + ty] - 1];
		swap(state.p[tx * N + ty], state.p[sx * N + sy]);
		state.space = tx * N + ty;
		if (dfs(depth + 1, r)) {
			path[depth] = r;
			return true;
		}
		state = tmp; //??±??????????????????
	}
	return false;
}

string ida(Puzzle in) {
	in.MD = getAllMD(in);

	for (limit = in.MD; limit < LIMIT; limit++) {
		state = in;
		if (dfs(0, -100)) {
			string ans = "";
			for (int i = 0; i < limit; i++) ans += dir[path[i]]; //????°???????limit??¨??????????????°?§??????????
			return ans;
		}
	}
	return "unsolvable";
}

int main() {
	for (int i = 0; i < N2; i++) {
		for (int j = 0; j < N2; j++) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}

	Puzzle in;
	for (int i = 0; i < N2; i++) {
		cin >> in.p[i];
		if (!in.p[i]) {
			in.p[i] = N2; //isTarget?????????
			in.space = i;
		}
	}

	string ans = ida(in);
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 1212
# include <bits/stdc++.h>
using namespace std;
const int maxn=1e6;
int main ()
{
	string s;
	cin>>s;
	int p;
	long long ans=0;
	int n=s.length();
	int sum=0;
	for (int i=0;i<n;++i)
	   {
	   	 if (s[i]=='W')
	   	   {
	   	     sum++;
	   	     ans=ans+(i+1-sum);
		   }
	   }
	printf ("%lld\n",ans);
	return 0;
 } 

Measured memory_bytes: 640
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Make a Rectangle
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	var temp int
	A := make(map[int]int, N)
	for i := 0; i < N; i++ {
		temp = nextInt()
		A[temp]++
	}

	B := make([]int, 0)
	for i, v := range A {
		if v >= 2 {
			B = append(B, i)
		}
	}

	if len(B) == 0 {
		fmt.Println("0")
	} else {
		sort.Sort(sort.Reverse(sort.IntSlice(B)))
		if A[B[0]] >= 4 {
			fmt.Println(B[0] * B[0])
		} else {
			fmt.Println(B[0] * B[1])
		}
	}
}


Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll par[10005];
ll find(ll x){
    if(par[x]<0)return x;
    return par[x]=find(par[x]);
}
void unite(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return;
    par[y]=x;
}

void solve(){
    ll v,e;cin>>v>>e;
    memset(par,-1,sizeof(par));

    vl s(e),t(e);
    vp a;
    rep(i,e){
        ll w;cin>>s[i]>>t[i]>>w;
        a.push_back(pl(w,i));
    }
    sort(all(a));

    ll ans=0;
    rep(i,a.size()){
        if(find(s[a[i].second])!=find(t[a[i].second])){
            ans+=a[i].first;
            unite(s[a[i].second],t[a[i].second]);
        }
    }
    cout<<ans<<endl;
}

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



Measured memory_bytes: 6596
s = list(map(int, input().split()))
n, m = int(s[0]), int(s[1])
cl = []
for i in range(n):
  cl.append(input())
  
for i in range(n):
  for j in range(m):
    if cl[i][j]=='#':
      st = False
      if i>0 and cl[i-1][j]=='#':
        st = True
        continue
      elif i<n-1 and cl[i+1][j]=='#':
        st = True
        continue
      elif j>0 and cl[i][j-1]=='#':
        st = True
        continue
      elif j<m-1 and cl[i][j+1]=='#':
        st = True
        continue
      if st:
        continue
      else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#define  REP(i, s, e) for (register int i = (s), end_##i = (e); i <= end_##i; i++)
#define DREP(i, s, e) for (register int i = (s), end_##i = (e); i >= end_##i; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) (a < (b) ? a = (b) : a)
#define chkmin(a, b) (a > (b) ? a = (b) : a)

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;
const double pi = acos(-1), eps = 1e-8;

template <typename T> T read()
{
	T ans(0), flag(1);
	char c(getchar());
	while (!isdigit(c))
	{
		if (c == '-') flag = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * flag;
}

void file(string s)
{
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int m, n, k;

int main()
{
#ifdef CraZYali
	file("D");
#endif
	double a, b, x;
	cin >> a >> b >> x;
	double V = a * a * b ;
	double theta;
	if (V / 2 < eps + x) theta = atan(a * a / 2 / (V - x) * a);
	else theta = atan(2 * x / a / b / b);
	theta = theta / pi * 180;
	printf("%.8lf\n", 90 - theta);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        vector<int> a(m);
        for (int j = 0; j < m; j++)
        {
            cin >> a[j];
        }
        int f = 0;
        for (int j = 0; j < m; j++)
        {
            f += a[j] * b[j];
        }
        if (f > -c)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	int x;
	cin >>x;
	int ans;
	int umin=x/100;
	int mmin=umin*105;
	umin*=100;
	cout <<((umin <= x and x <= mmin)?1:0)<<endl;
	
}


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

#define MAX 100005

int A[MAX], n;

int partition(int p, int r)
{
	int x, i, j;
	x = A[r];
	i = p - 1;
	for (j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

int main()
{
	int i, q;
	cin >> n;
	for (i = 0; i < n; i++)cin >> A[i];
	q = partition(0, n - 1);
	for (i = 0; i < n; i++) {
		if (i)cout << " ";
		if (i == q)cout << "[";
		cout << A[i]; 
		if (i == q)cout << "]";

	}
	cout << endl;
}



Measured memory_bytes: 3468
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Readln(b);
    if a > b then
      Writeln(a-1)
    else
       Writeln(a);
    Readln;

  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
s = input()
t = input()
ans = 10**9 + 7
for i in range(len(s) - len(t) + 1):
    trystr = s[i:i+len(s)+1]
    tryans = 0
    for j in range(len(t)):
        if trystr[j] != t[j]:
            tryans += 1
    if tryans <= ans:
        ans = tryans
print(ans)


Measured memory_bytes: 9044
<?php
    // get inputs from stdin
    $input = intval(fgets(STDIN));
    // when value is 1
    if($input === 1) {
        print_r(1);

    }
    // when value is odd 
    else if($input % 2 === 1) {
        print_r(((intval($input/2) + 1)/$input));
    }

    // when value is even
    else {
        print_r(0.5);
    }

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;


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

  ll ans = 0;
  for (ll i = 1; i < n; i++) {
    ans += i;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    long long H[N+2];

    for(int i = 1; i <= N; i++){
        cin >> H[i];
    }

    H[0] = H[1] -1;
    H[N+1] = H[N];

    int res = 1;

    for(int i = 1; i <= N;){
        if(H[i] > H[i+1] + 1){
            res *= 0;
            break;
        }
        else if(H[i] == H[i+1] + 1){
            H[i]--;
            if(H[i] < H[i-1]){
                res *= 0;
                break;
            }
            i += 2;
        }
        else{
            if(H[i] < H[i-1]){
                res *= 0;
                break;
            }
            else if(H[i] > H[i-1]){
                H[i]--;
            }
            i++;
        }
    }

    if(res){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,fl,siz[N],b[N],fa[N];
vector<int> e[N];
ll a[N],f[N],ans[N];
unordered_map<ll,int> h;
bool cmp(int x,int y){return a[x]<a[y];}
void work(int x){
	f[x]=siz[x]-1;
	for (auto y : e[x]){work(y);f[x]+=f[y];}
}
void calc(int x,ll s){
	ans[x]=f[x]+s+n-siz[x];
	for (auto y : e[x])
	calc(y,ans[x]-f[y]-siz[y]);
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) {scanf("%lld",a+i);h[a[i]]=i;b[i]=i;siz[i]=1;}
	sort(b+1,b+n+1,cmp);
	for (int i=n;i>1;i--){
		int x=b[i];
		fa[x]=h[a[x]+siz[x]-n+siz[x]];
		if (!fa[x]){puts("-1");return 0;}
		siz[fa[x]]+=siz[x];
		e[fa[x]].push_back(x);
	}
	work(b[1]);
	calc(b[1],0);
	for (int i=1;i<=n;i++)
	if (ans[i]!=a[i]){puts("-1");return 0;}
	for (int i=2;i<=n;i++) printf("%d %d\n",fa[b[i]],b[i]);
	return 0;
}

Measured memory_bytes: 16804
a,b,c = gets.chomp.split.map(&:to_f)

s = (a * b * Math.sin(c * Math::PI / 180)) * 0.5
l = (a + b) + (a*a + b*b - 2*a*b*Math.cos(c * Math::PI / 180)) ** 0.5
h = b * Math.sin(c * Math::PI / 180)

puts s
puts l
puts h

Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef long long lld;

const lld MAX=(1e13)+1;

vector<pair<int,lld>> th;

void find_th(){
    th.push_back(make_pair(0,0));
    th.push_back(make_pair(1,1));
    for(lld i=2;;i++){
        lld ax=i*i*i*i*i;
        th.push_back(make_pair(i,ax));
        if(ax>MAX)break;
    }
}

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lld x;
    cin>>x;
    find_th();
    lld a=0, b=0;
    for(int i=0;i<th.size();i++){
        for(int j=0;j<th.size();j++){
            if(th[i].second-th[j].second==x){
                a=th[i].first;
                b=th[j].first;
            }
            if(th[i].second+th[j].second==x){
                a=th[i].first;
                b=-th[j].first;
            }
        }
    }
    cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 3624