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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10;
int n, a, b, c;
string s[maxn];
vector<char> ans;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    s[n] = s[n - 1];
    for (int i = 0; i < n; i++)
    {
        if (s[i] == "AB")
        {
            if (a == 0 && b == 0)
            {
                cout << "No";
                return 0;
            }
            if (a > b)
            {
                ans.pb('B');
                b++;
                a--;
            }
            else if (b > a)
            {
                ans.pb('A');
                a++;
                b--;
            }
            else
            {
                if (s[i + 1] == "BC")
                {
                    ans.pb('B');
                    b++;
                    a--;
                }
                else
                {
                    ans.pb('A');
                    a++;
                    b--;
                }
            }
        }
        else if (s[i] == "BC")
        {
            if (c == 0 && b == 0)
            {
                cout << "No";
                return 0;
            }
            if (c > b)
            {
                ans.pb('B');
                b++;
                c--;
            }
            else if (b > c)
            {
                ans.pb('C');
                c++;
                b--;
            }
            else
            {
                if (s[i + 1] == "AB")
                {
                    ans.pb('B');
                    b++;
                    c--;
                }
                else
                {
                    ans.pb('C');
                    c++;
                    b--;
                }
            }
        }
        else
        {
            if (a == 0 && c == 0)
            {
                cout << "No";
                return 0;
            }
            if (a > c)
            {
                ans.pb('C');
                c++;
                a--;
            }
            else if (c > a)
            {
                ans.pb('A');
                a++;
                c--;
            }
            else
            {
                if (s[i + 1] == "BC")
                {
                    ans.pb('C');
                    c++;
                    a--;
                }
                else
                {
                    ans.pb('A');
                    a++;
                    c--;
                }
            }
        }
    }
    cout << "Yes";
    for (auto &w : ans)
        cout << endl << w;
	return 0;
}


Measured memory_bytes: 6916
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]

inds=[[-1]*N for _ in range(N)]
cnt=0
for i in range(N):
    for j in range(i+1,N):
        inds[i][j]=cnt
        cnt+=1

NN=(N*(N-1))//2
edges=[[] for _ in range(NN)]
nums = [0]*NN

for i in range(N):
    sis=[0]*(N-1)
    for j in range(N-1):
        src, dst = sorted([i,A[i][j]-1])
        sis[j] = inds[src][dst]

    for src,dst in zip(sis[:-1],sis[1:]):
        edges[src].append(dst)
        nums[dst]+=1

arr = [i for i,n in enumerate(nums) if n==0]

ans=0
cnt=0
while len(arr)>0:
    ans+=1
    cnt+=len(arr)
    narr=[]
    for src in arr:
        for dst in edges[src]:
            nums[dst]-=1
            if nums[dst]==0:
                narr.append(dst)
    arr=narr

if cnt < NN:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 124720
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,H,W,cnt=0;
  cin>>N>>H>>W;
  int A[N],B[N];
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
    if(A[i]>=H&&B[i]>=W) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int A,B;
    cin >> A >> B;
    stack<int> sta;


    map<int,int> r;
    int i = 2;
    while(A != 1){
        if(A % i == 0){
            if(!r.count(i)){
                r.insert(make_pair(i,0));
                sta.push(i);
            }
            A /= i;
            r.insert(make_pair(i,r.at(i)++));
        }else{
            i++;
        }
    }
    i = 2;
    int cnt = 0;
    while(B != 1){
        if(B % i == 0){
            cnt++;
            if(!r.count(i)){
                r.insert(make_pair(i,1));
                sta.push(i);
            }else if(cnt > r.at(i)){
                r.insert(make_pair(i,r.at(i)++));
            }
            B /= i;
        }else{
            i++;
            cnt = 0;
        }
    }
    long ans = 1;
    while(!sta.empty()){
        ans *= pow(sta.top(), r.at(sta.top()));
        sta.pop();
    }
    
    cout <<  ans << endl;
    

    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

int fact(int n){
  int ret = 1;
  for(int i = 1; i <= n; i++)
   ret *= i;
  return ret;	
}

void solve(){
	int n;
	while(cin >> n){
	  cout << fact(n) << endl;	
    }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  string s;
  cin >> s;
  if(s == "A") cout << "T";
  else if(s == "T") cout << "A";
  else if(s == "G") cout << "C";
  else cout << "G";
  hinata;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.next();
        final int N = s.length();
        int a = N;
        int z = 0;
        
        for (int i = 0; i < N; i++) {
            if (s.charAt(i) == 'A') {
                a = Math.min(a, i);
            } else if (s.charAt(i) == 'Z') {
                z = Math.max(z, i);
            }
        }
        
        out.println(N > 2 ? z - a + 1 : N);
        
        out.flush();
    }
}

Measured memory_bytes: 26104
N, M = map(int, input().split())
A = list(map(int, input().split()))

S = [0] * (N+1)
for i in range(N) :
    S[i+1] = S[i] + A[i]

cat = {}
for s in S :
    mod = s % M
    if mod in cat :
        cat[mod] += 1
    else :
        cat[mod] = 1

def comb(n, k) :
    p = 1
    d = 1
    for i in range(k) :
        p *= (n - i)
        d *=(i + 1)
    return p // d

ans = 0
for key, val in cat.items() :
    if val < 2 :
        continue
    ans += comb(val, 2)

print(ans)


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

long long N, A, B;
long long X[100005];

int main(){
	cin >> N >> A >> B;
	for(int i = 0; i < N; i++){
		cin >> X[i];
	}



	long long ans = 0;
	long long cur = 0;
	while(cur < N - 1){
		//cout << "cur = " << cur << " ans " << ans << endl;
		if(A * (X[cur+1] - X[cur]) > B){
			cur++;
			ans += B;

		}else{
			ans += A * (X[cur+1] - X[cur]);
			cur++;
		}
	}
	cout << ans << endl;



}



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

int main() {
  int N;
  cin >> N;
  int Hs[N];
  for(int i=0; i < N; i++){
      cin >> Hs[i];
  }
  int ans = 1;
  for(int i=1; i < N; i++){
      ans++;
      for(int j=0; j < i; j++){
          if(Hs[j] > Hs[i]){
              ans--;
              break;
          }
      }
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

int ans[2005];

int N, X, Y;

int main(void) {

	cin >> N >> X >> Y;

	for (int i = 1; i <= N - 1; i++) {
		for (int j = i + 1; j <= N; j++) {
			int d = j - i;
			d = min(d, abs(j - Y) + 1 + abs(X - i));

			ans[d]++;
		}
	}

	for (int i = 1; i <= N - 1; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

int t;
int n;
int A[101];

int main(){
	cin >> t;
	for(int it = 0; it < t; it++){
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> A[i];
		}
		int mx = max(0,A[1] - A[0]);
		int mn = max(0,A[0] - A[1]);
		for(int i = 2; i < n; i++){
			int val = A[i] - A[i-1];
			if(mx < val) mx = val;
			val = A[i-1] - A[i];
			if(mn < val) mn = val;
		}
		cout << mx << " " << mn << endl;
	}

	return 0;
}



Measured memory_bytes: 3016
package main
import (
    "fmt"
    "strings"
)

func main(){
    var s string
    var ls []string
    prev := "hoge"
    flag := true
    fmt.Scan(&s)
    ls = strings.Split(s,"")
    for _,moji := range ls{
        if moji==prev{
            fmt.Println("Bad")
            flag = false
            break
        }
        prev = moji
    }
    if flag {
        fmt.Println("Good")
    }
}

Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

void convert(int pos, int h, int w, int &i, int &j) {
    i = pos / w, j = pos % w;
    if (i % 2)
        j = w - j - 1;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    vector<int> series(h*w, 0);
    for (int t = 0; t < h*w; t++) {
        int i = t / w;
        int j = t % w;
        if (i % 2) {
            j = w - 1 - j;
        }
        series[t] = a[i][j];
    }

    vector<vector<int>> ans;

    for (int i = 0; i < h*w-1; i++) {
        if (series[i] % 2) {
            int a1, b1, a2, b2;
            series[i]--, series[i + 1]++;
            convert(i, h, w, a1, b1);
            convert(i+1, h, w, a2, b2);
            ans.push_back({ a1+1, b1+1, a2+1, b2+1 });

        }
    }

    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }

    
    return 0;
}

Measured memory_bytes: 10928
#include <cstdio>
#include <map>
typedef long long ll;
const int Mod=1e9+7;
const int maxn=1000000+5;
using namespace std;
ll a[25]={1,2,4,5,8,10,13,14,18,21,26,28,33,36,40,41,46,50,57,60,68};
map<ll,ll> mp;//记忆化

ll dfs(ll x) {
    if(x<=20)
        return a[x];
    if(mp[x])
        return mp[x];
    if(x%2)
        return mp[x]=(2*dfs(x/2)%Mod+dfs(x/2-1)%Mod)%Mod;
    else
        return mp[x]=(2*dfs(x/2-1)%Mod+dfs(x/2)%Mod)%Mod;
}

int main() {
    ll n;
    scanf("%lld",&n);
    printf("%lld\n",dfs(n));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define mp make_pair
using namespace std;

int n,bef,a[N];
vector< pair<int,int> > v;

int main() {

  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
  }
  sort(a+1,a+1+n,greater<int>());
  for(int i=1;i<=n;i++) {
    int tut=i;
    while(a[i]==a[i+1] && i+1<=n) i++;
    v.push_back(mp(a[i],i-tut+1));
  }
  for(int i=0;i<v.size();i++) {
    if(v[i].second>=4) {
      if(bef) {
        printf("%lld",1ll*bef*v[i].first);
      }
      else {
        printf("%lld",1ll*v[i].first*v[i].first);
      }
      return 0;
    }
    else if(v[i].second>=2) {
      if(bef) {
        printf("%lld",1ll*bef*v[i].first);
        return 0;
      }
      else {
        bef=v[i].first;
      }
    }
  }
  printf("0");

}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
const int maxn = 2000050;
const int zqc = 1e9+7;
typedef long long ll;
int n, m, sp, h;
ll ans;

int main()
{
	scanf("%d%d",&n,&m);
	if(abs(n-m)>1) return 0*printf("0");
	ans = 1; h = m-(n-1);
	fo(i,1,n) ans = (ans*i)%zqc;
	fo(i,1,m) ans = (ans*i)%zqc;
	if(h==1) ans = (ans*2)%zqc;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
//21:02 -

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int d, x;
  int a[105];

  cin >> n >> d >> x;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int cnt = n;
  for(int i = 0; i < n; i++){
    for(int k = 1; ; k++){
      int work = k * a[i] + 1;
      if(work > d) break;
      cnt++;
    }
  }
  cout << cnt + x << endl;

  return 0;
}


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

int main(){
  int x[100],i=0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
    
      x[i-2]=x[i-2]+x[i-1];
      i=i-2;
      
    } else if ( s[0] == '-' ){
      
      x[i-2]=x[i-2]-x[i-1];
      i=i-2;
    } else if ( s[0] == '*' ){
      
      x[i-2]=x[i-2]*x[i-1];
      i=i-2;
    } else {
      
      x[i] = atoi(s);   
    }
    i++;
  
}    printf("%d\n",x[0]);

  return 0;
}

Measured memory_bytes: 548
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int>w(n);
  rep(i,n) cin >> w.at(i);
  int sum=0;
  rep(i,n) sum += w.at(i);
  int mi = sum;
  rep(i,n){
    int s1=0;
    rep(j,i){
    s1 += w.at(j);
    }
    int s2 = sum - s1;
    mi = min(mi,abs(s2-s1));
  }
  cout << mi <<endl;
}

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

int main() {
    int i;
    string j;

    cin >> j;
    if(j[0] == j[1] && j[1] == j [2] )cout << "Yes" << endl;
    else if(j[1] == j[2] && j[2] == j[3])cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    string ans="Impossible";
    if(a%3==0||b%3==0||c%3==0){ans="Possible";}
    out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    int a,b,c,d,n; cin>>a>>b>>c>>d>>n;
    int e=a*4,f=b*2;
    int g=min({e,f,c});
    if(g*2<=d){
        cout<<g*n<<endl;
    }else{
        cout<<d*(n/2)+g*(n-(n/2)*2)<<endl;
    }
}

Measured memory_bytes: 256
N=input()
N=int(N)
s = [0 for i in range(N)]
#sの入力
for i in range(N):
    s[i]=input()

M=input()
M=int(M)
t = [0 for i in range(M)]
#sの入力
for i in range(M):
    t[i]=input()

#処理
ans=0
for i in range(N):
    count=0
    #ターゲット
    target=s[i]
    #判定
    #プラス分
    for j in range(N):
        if target==s[j]:
            count+=1
    #マイナス分
    for j in range(M):
        if target==t[j]:
            count-=1
    #結果の更新
    if ans<count:
        ans=count

print(ans)

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

#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()

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

int main() {

    int N;
    cin >> N;
    
    vector<int> a(N);
    vector<vector<int>> x(N), y(N);
    rep(i, N) {
        cin >> a[i];
        rep(j, a[i]) {
            int xs, ys;
            cin >> xs >> ys;
            x[i].push_back(xs - 1);
            y[i].push_back(ys);
        }
    }

    int ans = 0;
    rep(i, 1 << N) {
        if([&]{
            rep(j, N) {
                if((1 << j) & i){
                    rep(k, a[j]) {
                        if(y[j][k] == 1 && ((1 << x[j][k]) & i) == 0)return false;
                        if(y[j][k] == 0 && ((1 << x[j][k]) & i) != 0)return false;
                    }
                }
            }
            return true;
        }())chmax(ans, __builtin_popcount(i));
    }

    cout << ans << '\n';

}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 ANS1 = 0;
	SINT32 ANS2 = 0;

	cin >> N;

	vector<SINT32> DATA(N);
	vector<SINT32> DATA2(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
		DATA2[i] = DATA[i];
	}

	sort(DATA2.begin(),DATA2.end());
	ANS1 = DATA2[(N/2)-1];
	ANS2 = DATA2[N/2];

	rep(i,0,N) {
		if (DATA[i] <= ANS1) {
			cout << ANS2 << endl;
		} else {
			cout << ANS1 << endl;
		}
	}

	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b <= c) {
		cout << c - (a - b) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
mod=10**9+7
ans=[0]*(k+1)
anss=0
for i in range(k,0,-1):
  m=pow(k//i,n,mod)
  for j in range(i*2,k+1,i):m-=ans[j]
  ans[i]=m%mod
  anss+=ans[i]*i
  anss%=mod
print(anss)

Measured memory_bytes: 11128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100000000
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n,m;
	cin>>n>>m;
	ll k;
	cin>>k;
	vector<ll> a(n),b(m);
	forn(i,n)	cin>>a[i];
	forn(i,m)	cin>>b[i];
	ll sum=a[0];
	ll pos=-1;
	for(ll i=1;i<n;i++){
		a[i]+=a[i-1];
		sum=a[i];
		if(sum>1e10){
			pos=i;
			break;
		}
	}
	if(pos!=-1)		a.erase(a.begin()+(pos),a.end());
	sum=b[0];
	pos=-1;
	for(ll i=1;i<m;i++){
		b[i]+=b[i-1];
		sum=b[i];
		if(sum>1e10){
			pos=i;
			break;
		}
	}
	if(pos!=-1)		b.erase(b.begin()+(pos),b.end());
	vector<ll>::iterator it1,it2,it3,it4;
	
	//forn(i,b.size())	cout<<b[i]<<' ';
	it1=lb(a,k);
	it2=ub(a,k);
	ll ans=it1-a.begin()+1;
	if(it1==it2)	ans--;
	it3=lb(b,k);
	it4=ub(b,k);
	ll ans2=it3-b.begin()+1;
	if(it3==it4)	ans2--;
	ans=max(ans,ans2);
	if((it1==it2&&it1==a.begin())||(it3==it4&&it3==b.begin())){
		cout<<ans;
		return 0;
	}
	pos=it1-a.begin();
	if(it1==it2)	pos--;
	while(pos>=0){
		ll x=a[pos];
		ll d=k-x;
		it3=lb(b,d);it4=ub(b,d);
		ans2=pos+1;
		ans2+=(it3-b.begin())+1;
		if(it3==it4)	ans2--;
		pos--;
		//cout<<ans2<<endl;
		ans=max(ans,ans2);
	}
	cout<<ans;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  cout << 360/gcd(360,n) << endl;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int d, t, s;
    cin>> d>> t>> s;

    cout << ( d > (t*s) ? "No\n"  : "Yes\n");


    return 0;
}




Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

ll N, K;
ll w[100000];
ll d[100000];

ll f(ll x)
{
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (w[i] <= x) {
			ans = min(ans + (x - w[i]) / d[i] + 1, linf);
		}
	}
	return ans;
}

ll rec(ll a, ll b, ll x)
{
	ll mid = a + (b - a) / 2;
	ll k = f(mid);
	ll l = f(mid - 1);
	if (k < x) {
		return rec(mid + 1, b, x);
	}
	else if (l >= x) {
		return rec(a, mid - 1, x);
	}
	return mid;
}

int main(int argc, char* argv[])
{
	scanf("%lld%lld", &N, &K);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &w[i], &d[i]);
	printf("%lld\n", rec(0, (1ll << 63) - 1, K));

	return 0;
}


Measured memory_bytes: 1920
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  int N,m[1001],X,co=0;
  cin >> N >> X;
  REP(i,N)cin >> m[i];
  REP(i,N){
    X = X-m[i];
    co++;
  }
  sort(m,m+N);
  co += X/m[0];
  cout << co << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

vector<ll> vec;

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

    ll N,M;
    string S;
    cin >> N>>M;
    vector<ll> a(M),b(M);
    REP(i, M)
        cin >> a.at(i) >> b.at(i);

    REP(i,M){
        if(a.at(i)==1){
            vec.push_back(b.at(i));
        }
        if(b.at(i)==N){
            vec.push_back(a.at(i));
        }
    }

    sort(vec.begin(), vec.end());

    bool flag = flase;

    REP(i,vec.size()-1){
        if(vec.at(i)==vec.at(i+1)){
            flag = true;
        }
    }

    if(flag){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 5620
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int cnt = 0;
    for(int i=0; i<n-2; i++){
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            cnt++;
        }
    }

    COUT(cnt);

    return 0;
}

Measured memory_bytes: 256
import sys
h, w = map(int, input().split())
sq = []

for i in range(h):
    sq.append(input())

def is_valid(i, j):
#    global sq
    valid = False
    if i > 0 and sq[i-1][j] == '#':
        valid = True
    elif i < h-1 and sq[i+1][j] == '#':
        valid = True
    elif j > 0 and sq[i][j-1] == '#':
        valid = True
    elif j < w-1 and sq[i][j+1] == '#':
        valid = True
    return valid

for i in range(h):
    for j in range(w):
        c = sq[i][j]
        if c == '#':
            if not is_valid(i, j):
                print('No')
                sys.exit()

print('Yes')



Measured memory_bytes: 39280
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);
        int A = Integer.parseInt(SC.next());
        int B = Integer.parseInt(SC.next());

        System.out.println(LCM(A,B));
    }


    long LCM(long a, long b){
        return a / GCD(a, b) * b;
    }

    long GCD(long a, long b){
        if(b == 0) return a;
        return GCD(b, a%b);
    }

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


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

using namespace std;

typedef long long int lo;
typedef pair<int,int> PII;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR for(int i=1;i<=  n;i++)
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mid (start+end)/2

const lo mod = 1000000007;
const lo li = 100005;
const lo inf = 1000000000;
const lo MAX = 1000000000000000000;
const lo MIN = -1000000000000000000;
const lo LOG = 30;

lo n,m,cev,k,a[5];

int main(){
	scanf("%lld %lld %lld",&a[1],&a[2],&a[3]);
	sort(a+1,a+n+1);
	cev=a[1]*a[2]/2;
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
	string s;
	cin >> s;
	int N = s.size();
	const int inf = 1e9;
	vector<vector<int>> dp(N + 1, vector<int>(4, 0));
	for(int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
		    dp[i][j] = -inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 4; j++) {
			for(int k = 0; k < 4; k++) {
				if (i + k > N) continue;
				if (i - j < 0) continue;
				if (j != k || s.substr(i - j, j) != s.substr(i, k)) {
					dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
				}
			}
		}
	}

	int ans = 0;
	for(int j = 0; j < 4; j++) {
		ans = max(ans, dp[N][j]);
	}
	cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 11412
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEqueue solver = new DEqueue();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEqueue {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), K = in.nextInt(), a[] = new int[n], vis[] = new int[n];
            for (int i = 0; i < n; ++i) a[i] = in.nextInt();

            int ans = 0;
            for (int i = 0; i <= Math.min(n, K); ++i) {
                for (int j = 0; i + j <= K && i + j <= n; ++j) {
                    int qt = 0, cur = 0;
                    for (int k = 0; k < i; ++k) {
                        vis[qt++] = a[k];
                        cur += a[k];
                    }
                    for (int k = 0; k < j; ++k) {
                        vis[qt++] = a[n - 1 - k];
                        cur += a[n - 1 - k];
                    }
                    Arrays.sort(vis, 0, qt);

                    int remove = 0;
                    for (int k = 0; k < qt && k < K - i - j && vis[k] < 0; ++k) remove += vis[k];

                    ans = Math.max(ans, cur - remove);
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    vin p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    int sum=0;
    rep(i,k)sum+=p[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = r() - 1
	}

	var nowIdx int
	var ct int
	for {
		nextIdx := a[nowIdx]

		a[nowIdx] = -1

		if nextIdx == -1 {
			ct = -1
			break
		}

		if nowIdx == 1 {
			break
		}

		nowIdx = nextIdx
		ct++
	}
	fmt.Println(ct)
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    VL a(2);
    cin>>a[0]>>a[1];
    cout<<((a[0]<=8&&a[1]<=8) ? "Yay!":":(" );
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    auto f = [](int x) {
                 vector<int> num;
                 while (x > 0) {
                     num.push_back(x%10);
                     x /= 10;
                 }
                 rep(i, sz(num)/2) {
                     if (num[i] != num[sz(num)-1-i]) return false;
                 }
                 return true;
             };
    int ans = 0;
    for (int i = a; i <= b; ++i) {
        if (f(i)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main(void)
{
    int n,x,y,z,a[101],b[101],c[101],i,j,w,flg[101];
	scanf("%d",&n);
	scanf("%d",&x);
	for(i=1;i<=x;i++){
	    scanf("%d",&a[i]);
	}
	scanf("%d",&y);
	for(i=1;i<=y;i++){
	    scanf("%d",&b[i]);
	}
	scanf("%d",&z);
	w=z;
	for(i=1;i<=z;i++){
	    scanf("%d",&c[i]);
	}
	for(i=1;i<=100;i++) flg[i]=0;
	for(i=1;i<=y;i++){
	    for(j=1;j<=z;j++){
		    if(b[i]==c[j]){
			    flg[j]=1;
			}
		}
	}for(i=1;i<=x;i++){
	    for(j=1;j<=z;j++){
		    if(a[i]==c[j]&&flg[j]==0){
			    w--;
			}
		}
	}
	printf("%d\n",w);
	return 0;
}

Measured memory_bytes: 2752
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,a[100000],cnt=0,ans=1;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(int i=0; i<n; i++) {
    if(a[i]==a[i+1]) {
      cnt++;
      ans*=a[i];
      if(cnt==2) {
        cout << ans << endl;
        return 0;
      }
      i++;
    }
  }
  cout << 0 << endl;
}


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

int main(){
    int h,w;
    bool ans = true,check = false;
    vector< vector<char> > target;
    cin >> h >> w;
    target.resize(h);
    for(int i=0;i<h;i++){
        target[i].resize(w);
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> target[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(target[i][j] == '#'){
                if(i > 0){
                    if(target[i-1][j]=='#'){
                        check = true;
                    }
                }
                if(i < h-1){
                    if(target[i+1][j]=='#'){
                        check = true;
                    }
                }
                if(j > 0){
                    if(target[i][j-1]=='#'){
                        check = true;
                    }
                }
                if(j < w-1){
                    if(target[i][j+1]=='#'){
                        check = true;
                    }
                }
                if(!check){
                    ans = false;
                }
                check = false;
            }
        }
    }
    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
template<class T,class U>constexpr bool bit(const T n,const U k){return (n>>k)&1;}

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"start"<<endl;
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;

//__builtin_popcount(S);
//#define int ll
//vector<vector<int>> data(3, vector<int>(4));
//vector.resize(a,vector<int>(b,-1));
//vector<vector<vector<要素の型>>> 変数名(要素数1, vector<vector<要素の型>>(要素数2, vector<要素の型>(要素数3, 初期値)));



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

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

    ll ans=0;
    ll i,o,t,j,l,s,z;
    cin>>i>>o>>t>>j>>l>>s>>z;
    ans+=o;
    int count=0;
    if(i%2==1) count++;
    if(j%2==1) count++;
    if(l%2==1) count++;
    if(count>=2 && i>=1 && j>=1 && l>=1) ans+=3,i--,j--,l--;
    ans+=(i/2+j/2+l/2)*2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, arr[3010], dp[3010][3010];
long long fun(long long x, long long y)
{
    if (x > y)
        return 0;
    if (x > n - 1 || y < 0)
        return 0;
    if (dp[x][y] != -1)
        return dp[x][y];
    if ((n - 1 - (y - x)) % 2 == 0)
        return dp[x][y] = max(arr[x] + fun(x + 1, y), arr[y] + fun(x, y - 1));
    return dp[x][y] = min(fun(x + 1, y) - arr[x], fun(x, y - 1) - arr[y]);
}
int main()
{
    cin >> n;
    for (long long x = 0; x < n; x++)
        cin >> arr[x];
    memset(dp, -1, sizeof(dp));
    long long ans = fun(0, n - 1);
    cout << ans << endl;
}

Measured memory_bytes: 71168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
using namespace std;

int main(){
    int n,k ;
    string s ;
    cin >> n >> s >> k ;
    char key = s.at(k-1) ;
    for (int i = 0; i < s.size(); i++)
    {
        if (s.at(i) != key)
        {
            s.at(i) = '*' ;
        }
        
    }
    cout << s << endl ;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1; i<10; i++){
            for(int k=i; k<10; k++){
                if(i*k==N){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        
        
        
        
        
        
        
        
        
        
        
        
          System.out.println("No");
        }
    }

Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
const int infty = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, r;
  cin >> n >> m >> r;
  vector<pair<int, pair<int, int> > > grh(m);
  for (int i = 0; i < m; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    grh.push_back({d, {s, t}});
  }
  vector<int> dst(n);
  for (int i = 0; i < n; i++) {
    if (i == r) {
      dst[i] = 0;
    } else {
      dst[i] = infty;
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto e : grh) {
      int d = e.first;
      int s = e.second.first;
      int t = e.second.second;
      if (dst[s] != infty) {
        dst[t] = min(dst[t], dst[s] + d);
      }
    }
  }
  for (auto e: grh) {
    int d = e.first;
    int s = e.second.first;
    int t = e.second.second;
    if (dst[s] != infty && dst[t] > dst[s] + d) {
      cout << "NEGATIVE CYCLE" << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (dst[i] == infty) {
      cout << "INF" << '\n';
    } else {
      cout << dst[i] << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3228
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	HashSet<Integer> set = new HashSet<Integer>();
	int N = Integer.parseInt(sc.next());
	int[] a = new int[N+1];
	for(int i = 1; i<=N; i++) {
	    a[i] = Integer.parseInt(sc.next());
	}
	int next = 1;
	int cnt = 0;
	for(int i = 0; i<N; i++) {
	    if(next == 2) {
		System.out.println(cnt);
		return;
	    }
	    if(set.contains(next)) {
		System.out.println(-1);
		return;
	    }
	    set.add(next);
	    next = a[next];
	    cnt++;
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 50616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

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

    string a;

    // 引数の受け取り
    cin >> a ;

    string ans = "";
    for (int i=0; i<a.size();i++){
        if(a[i]== '0'){
            ans += "0";
        }else if(a[i] == '1'){
            ans += "1";
        }else{
            if(ans.size()!=0){
                ans.erase(ans.size()-1, 1);
            } 
        }
    }

    cout << ans << endl;

    // 出力
    return 0;
}



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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int z=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k])
                {
                    if(a[i]+a[j]>a[k])
                    {
                        z++;
                    }
                }
            }
        }
    }
    cout<<z<<endl;
}


Measured memory_bytes: 3592