akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

bool check(const vector<int>& blocks){
	for(int i=0;i+1<blocks.size();i++){
		if(blocks[i] < blocks[i+1]) return false;
	}
	return true;
}

void dfs(vector<int>& blocks,int n,int c){
	if(!check(blocks)) return;
	if(c==0){
		//reverse(blocks.begin(),blocks.end());
		for(int i=0;i<blocks.size();i++){
			printf("%s%d",i==0 ? "" : " ",blocks[i]);
		}
		printf("\n");
		return;
	}

	for(int i=min(c,n);i>=1;i--){
		vector<int> next = blocks;
		next.push_back(i);
		dfs(next,n,c-i);
	}
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		vector<int> blocks;
		if(n==0) break;
		dfs(blocks,n,n);
	}
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double r;
  cin >> r;
  cout << 2 * acos(-1.0) * r << '\n';
}


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

int main() {
  int N,D,sum=0;
  cin >> N >> D;
  double X,Y,H;
  
  for(int i=0; i<N; i++) {
    cin >> X >> Y;
    H = sqrt(X*X + Y*Y);  
    if(H <= D) sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   range(i,0,n)
#define SZ(x) ((ll)(x).size())
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; }
int main() {
    ll N, ans;
    string S;
    cin >> N >> S;
    ans = 0;
    rep(x, N){
        ll res = 0;
        set<char> X, Y;
        rep(i, x){
            X.insert(S[i]);
        }
        range(j, x, N){
            Y.insert(S[j]);
        }
        set<char> Z;
        for(auto s:X) if(Y.count(s)) res++;
        chmax(ans, res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  int player = 1;
  rep(i,k){
    if(player == 1){
      if(a%2!=0){
        a--;
      }
      a /= 2;
      b += a;
      player = 2;
    }else{
      if(b%2!=0){
        b--;
      }
      b /= 2;
      a += b;
      player = 1;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	int h , n;
	cin >> h >> n;
	vector<pair < int , int > > a(n);
	for(int i = 0 ; i < n ; i++){
		int x , y;
		cin >> x >> y;
		a[i] = {x , y};
	}
	int dp[h + 1];
	dp[0] = 0;
	for(int i = 1; i <= h ; i++){
		dp[i] = 1000000000;
	}
	for(int i = 1 ; i <= h ; i++){
		for(int j = 0 ; j < n ; j++){
			dp[i] = min(dp[i] , dp[ max(i - a[j].first , 0)] + a[j].second);
		}
	}
	cout << dp[h] << endl;
 	return 0; 
}

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

char ch[MAX], op1[MAX], op2[MAX];
int len, cnt, ont;
int n1[MAX], n2[MAX];

int go1(void){
	int i, j;
	int c=cnt, o=ont;
	for (i=1;i<=o;i++){
		if (op1[i]=='*'){
			n1[i]*=n1[i+1];
			for (j=i+1;j<=c;j++){
				n1[j]=n1[j+1];
			}
			c--;
			for (j=i;j<=o;j++){
				op1[j]=op1[j+1];
			}
			o--;
			i--;
		}
	}
	for (i=1;i<=o;i++){
		if (op1[i]=='+'){
			n1[i]+=n1[i+1];
			for (j=i+1;j<=c;j++){
				n1[j]=n1[j+1];
			}
			c--;
			for (j=i;j<=o;j++){
				op1[j]=op1[j+1];
			}
			o--;
			i--;
		}
	}
	return n1[1];
}

int go2(void){
	int i, j;
	int o=ont, c=cnt;
	for (i=1;i<=o;i++){
		if (op2[i]=='+'){
			n2[i]+=n2[i+1];
		}else if (op2[i]=='*'){
			n2[i]*=n2[i+1];
		}
		for (j=i+1;j<=c;j++){
			n2[j]=n2[j+1];
		}
		c--;
		for (j=i;j<=o;j++){
			op2[j]=op2[j+1];
		}
		o--;
		i--;
	}
	return n2[1];
}

int main(void){
	int i;
	scanf("%s", &ch[1]);
	len=strlen(&ch[1]);
	for (i=1;i<=len;i+=2){
		n1[++cnt]=ch[i]-'0';
		n2[cnt]=n1[cnt];
	}
	for (i=2;i<=len;i+=2){
		op1[++ont]=ch[i];
		op2[ont]=op1[ont];
	}
	int r1, r2;
	r1=go1();
	r2=go2();

	int n;
	scanf("%d", &n);
	if (r1==n && r2==n) printf("U\n");
	else if (r1==n) printf("M\n");
	else if (r2==n) printf("L\n");
	else printf("I\n");
	return false;
}

Measured memory_bytes: 996
# C - GeT AC

N, Q = map(int, input().split())
S = input()

# ABCACAA = 0000100のようなリストを作る。ACが出てきたら1
L = [0]*(N)
for i in range(1, N):
    if S[i-1]=='A' and S[i]=='C':
        L[i] = 1

# 累積和を取る
Lsum = [0]*(N+1)
for i in range(N):
    Lsum[i+1] = Lsum[i]+L[i]

for _ in range(Q):
    l, r = map(int, input().split())
    print(Lsum[r] - Lsum[l])


Measured memory_bytes: 8516
#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()
#define MOD 1000000007
typedef long long ll;

int main() {
    int n, a;
    cin >> n >> a;
    int sum;
    REP(i, a){
        int num;
        cin >> num;
        sum += num;
    }
    if(sum >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main(): 

    L,R = map(int, input().split())

    min_value = 2019

    if R-L >= 2018:
        min_value = 0
    else:
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                min_value = min(min_value, (i * j) % 2019)

    print(min_value)


if __name__ == "__main__":
    main() 

Measured memory_bytes: 3060
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
mod=10**9+7

x.sort()
y.sort()

X=0
for i in range(0,n):
    X=(X+x[i]*(i-(n-1-i)))%mod

Y=0
for i in range(0,m):
    Y=(Y+y[i]*(i-(m-1-i)))%mod

print((X*Y)%mod)


Measured memory_bytes: 82916
import 'dart:convert';
import 'dart:io';

void main() async {
  List<int> NnD =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  var lines = stdin.transform(utf8.decoder).transform(LineSplitter());
  int N = NnD[0];
  int D = NnD[1];
  int D2 = D * D;
  int count = 0;

  await for (var line in lines) {
    List<int> XnY =
    line.split(" ").map((x) => int.parse(x)).toList();
    int X = XnY[0];
    int Y = XnY[1];
    if (X * X + Y * Y <= D2) {
      count += 1;
    }
  }
  print(count);
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    vector <int> a(n),b(n),c(n-1);
    loop(i,0,n) cin>>a[i];
    loop(i,0,n) cin>>b[i];
    loop(i,0,n-1) cin>>c[i];
    int ans=0;

    loop(i,0,n)
    {
        ans+=(b[a[i]-1]);
        if(i>0)
        {
            if(a[i]-1==a[i-1])
            {
                ans+=c[a[i-1]-1];
            }
        }
    }
    cout<<ans;

    return 0;
}


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

using namespace std;

#define int long long

const int maxn=3e5+5,inf=1e15;

int t[maxn],f[maxn],g[maxn],h[maxn],n,m,stk[maxn],tp,s[maxn],tmp[maxn];

inline int read(){
	int x=0,f=1;
	char p=getchar();
	while(!isdigit(p)){
		if(p=='-') f=-1;
		p=getchar();
	}
	while(isdigit(p)) x=(x<<3)+(x<<1)+(p^48),p=getchar();
	return x*f;
}

inline double slope1(int i,int j){
	return (1.0*(f[i]+s[i]+1.0*i*i/2-1.0*i/2-(f[j]+s[j]+1.0*j*j/2-1.0*j/2)))/(1.0*(i-j));
}

inline double slope11(int i,int j){
	return (1.0*(g[i]+s[i]+1.0*i*i/2-1.0*i/2-(g[j]+s[j]+1.0*j*j/2-1.0*j/2)))/(1.0*(i-j));
}

inline double slope2(int i,int j){
	return (1.0*(g[i+1]-s[i]+1.0*i*i/2+3.0*i/2-(g[j+1]-s[j]+1.0*j*j/2+3.0*j/2)))/(1.0*(i-j));
}

inline double slope3(int i,int j){
	return (1.0*(f[i-1]+s[i-1]+1.0*i*i/2-3.0*i/2-(f[j-1]+s[j-1]+1.0*j*j/2-3.0*j/2)))/(1.0*(i-j));
}

inline void dpf(){
	for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	stk[tp=1]=0;
	for(int i=1;i<=n;i++){
		while(tp>1&&( i >= slope1( stk[tp-1] ,stk[tp] ) )) tp--;
		f[i]=max(f[i-1],f[stk[tp]] -s[i] +s[stk[tp]] + (i-stk[tp]+1)*(i-stk[tp])/2 );
		while(tp>1&&( slope1( stk[tp-1],stk[tp] ) <= slope1(stk[tp-1] ,i ) )) tp--;
		stk[++tp]=i;
	}
}

inline void dpg(){
	for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	stk[tp=1]=0;
	for(int i=1;i<=n;i++){
		while(tp>1&&( i >= slope11( stk[tp-1] ,stk[tp] ) )) tp--;
		g[i]=max(g[i-1],g[stk[tp]] -s[i] +s[stk[tp]] + (i-stk[tp]+1)*(i-stk[tp])/2 );
		while(tp>1&&( slope11( stk[tp-1],stk[tp] ) <= slope11(stk[tp-1] ,i ) )) tp--;
		stk[++tp]=i;
	}
}

inline void cdq(int l,int r){
	if(l==r){
		h[l]=f[l-1]+g[r+1]+1-t[l];
		return;
	}
	int mid=(l+r)>>1,mx;
	cdq(l,mid);cdq(mid+1,r);
	tp=0;
	for(int i=r;i>=mid+1;i--){
		while(tp>1&&(slope2( stk[tp-1],stk[tp] ) >= slope2(stk[tp-1],i)) ) tp--;
		stk[++tp]=i;
	}
	for(int i=mid;i>=l;i--){
		while(tp>1&&(slope2(stk[tp-1],stk[tp]) >= i  )) tp--;
		tmp[i]=f[i-1]+g[stk[tp]+1] -s[stk[tp]] +s[i-1] + (stk[tp]-i+1)*(stk[tp]-i+2)/2;
	}
	tp=0;
	for(int i=l;i<=mid;i++){
		while(tp>1&&slope3(stk[tp-1],stk[tp]) <=slope3(stk[tp-1],i) ) tp--;
		stk[++tp]=i;
	}
	for(int i=mid+1;i<=r;i++){
		while(tp>1&&(slope3(stk[tp-1],stk[tp]) <=i )) tp--;
		tmp[i]=f[stk[tp]-1]+g[i+1]-s[i]+ s[stk[tp]-1] +(i-stk[tp]+1)*(i-stk[tp]+2)/2;
	}
	mx=-inf;
	for(int i=l;i<=mid;i++) mx=max(mx,tmp[i]),h[i]=max(h[i],mx);
	mx=-inf;
	for(int i=r;i>=mid+1;i--) mx=max(mx,tmp[i]),h[i]=max(h[i],mx);
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) t[i]=read();
	dpf();reverse(t+1,t+1+n);dpg();reverse(t+1,t+1+n);reverse(g+1,g+1+n);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	memset(h,128,sizeof(h));
	cdq(1,n);
	m=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		printf("%lld\n", max(f[x-1]+g[x+1],h[x]-y+t[x]));
	}
	return 0;
}

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

using namespace std;

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

int main(){
    int n;
    vector<long long int> arr;

    cin >> n;
    REP(i,3 * n){
        long long int tmp;
        cin >> tmp;
        arr.push_back(tmp);
    }
    sort(arr.begin(),arr.end());

    long long int sum = 0;


    REP(i,n){
        arr.pop_back();
        sum += arr[arr.size() - 1];
        arr.pop_back();
        // arr.erase(arr.begin());
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 6128
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
 
int main(void){
    int n, m;
    
    cin >> n >> m;
    
    vector<pair<int, int>> v;
    
    for(int i = 0; i < m; i++){
        pair<int, int> tmp;
        cin >> tmp.second >> tmp.first;
        v.push_back(tmp);
    }
    
    sort(v.begin(), v.end());
    
    int lastBridge = 0;
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(v[i].second <= lastBridge){
            
        } else {
            lastBridge = v[i].first - 1;
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int x[100];

int main()
{
 	int n;
  	cin >> n;
  	int a = 0;
  	for (int i = 0; i < n; ++i)
    {
     	cin >> x[i];
      	if (x[i] > a)
          a = x[i];
    }
  	int sol = 10000000;
    for (int p = 1; p <= a; ++p)
    {
      int sum = 0;
      for (int i = 0; i < n; ++i)
      {
    	int b = pow((x[i]-p), 2);
        sum += b;
      }
      sol = min(sum, sol);
  	}
  	cout << sol;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (unfoldr)

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    next :: Maybe Digits -> Maybe ([Int], Maybe Digits)
    next = fmap next'
      where
        next' :: Digits -> ([Int], Maybe Digits)
        next' = (,) <$> map snd . reverse <*> succDs
  mapM_ ((putChar 'a' >>) . putStrLn) . map (map toLEL) . unfoldr next . Just . zeroes $ n

type Digits = [(Int, Int)]

extend :: Digits -> Digits
extend [] = (1, 0) : []
extend ds@((m, k) : _) = (max m (succ k), 0) : ds

zeroes :: Int -> Digits
zeroes 1 = []
zeroes l  = extend . zeroes . pred $ l

succDs :: Digits -> Maybe Digits
succDs [] = Nothing
succDs ((m, k) : ds) | k < m = Just ((m, succ k) : ds)
succDs (_ : ds) = extend <$> succDs ds

showDs :: Digits -> String
showDs = ('a' :) . map (toLEL . snd) . reverse

toLEL :: Int -> Char
toLEL = toEnum . (fromEnum 'a' +)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 2172
X, K, D=map(int,input().split())
if D*K<abs(X):
    ans=abs(X)-D*K
else:
    p=abs(X)//D
    q=abs(X)%D
    if (K-p)%2==1:
        ans=abs(D-q)
    else:
        ans=q
print(ans)

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

int main(){
  int n, m;
  double sum;
  cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(int i = 0; i < n; i++)
    sum += a.at(i);
  sort(a.begin(),a.end());
  if(a.at(n-m) >= sum/(4*m))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 ll a[n+10],b[n+10]; 
 rep(i,0,n)cin>>a[i]>>b[i];
 map<pair<ll,ll>,ll>m;
 ll p,q;
 ll c=0;
 rep(i,0,n){
  rep(j,0,n){
   if(i==j)continue;
   p=a[i]-a[j];
   q=b[i]-b[j];
   m[{p,q}]++;
   c=max(c,m[{p,q}]);
  }
 }
 ll ans=n-c;
 if(n==1)ans=1;
 pr(ans);
return 0;}


Measured memory_bytes: 3692
# coding: utf-8
i = False
while True:
    line = input().rstrip().split()
    H = int(line[0])
    W = int(line[1])
    if H == 0 and W == 0:
        print("\n",end="")
        break
    if i:
        print("\n",end="")
    for i in range(H):
        for j in range(W):
            if i == 0 or j == 0 or i == H-1 or j == W-1:
                print("#",end="")
            else:
                print(".",end="")
        print("\n",end="")
    i =True


Measured memory_bytes: 7020
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 

 

 
int main(){
  int n;
  cin >> n;
  VI d1(n),d2(n);
  rep(i,n)cin >> d1.at(i) >> d2.at(i);
  int cnt=0;
  bool a=false;
  rep(i,n){
      if(d1.at(i)==d2.at(i)){
        cnt++;
        if(cnt==3)a=true;
      }
      else{
        cnt=0;
      }
  }
  if(a)cout << "Yes" << endl;
  else cout << "No" << endl;
} 


Measured memory_bytes: 3632
#include<iostream>
#include<string>

using namespace std;

int main() {
	int A, B, C, D;	cin >> A >> B >> C >> D;

	if (A*B >= C * D) {
		cout << A * B << endl;
		return 0;
	}
	cout << C * D << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
const int mod=1e9+7;
ll qp(ll k,ll x){
	ll res=1;while(x){
		if(x&1) res=res*k%mod;k=k*k%mod;x>>=1;
	}return res;
}ll cnt[maxn];
int main(){
	ll n,k;scanf("%lld%lld",&n,&k);
	for(int i=1;i<=k;i++){
		cnt[i]=qp(k/i,n);
	}ll ans=0;
	for(int i=k;i>=1;i--){
		for(int j=2*i;j<=k;j+=i){
			cnt[i]=(cnt[i]-cnt[j]+mod)%mod;
		}ans+=cnt[i]*i%mod;ans%=mod;
	}printf("%lld\n",ans);
}

Measured memory_bytes: 4568
N = int(input())
ls = list(map(int, input().split()))

if 0 in ls:
  print('0')
  exit()

goukei = 1
for i in ls:
  goukei *= i

  if goukei > 1000000000000000000:
    print('-1')
    exit()

print(int(goukei))

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int a,b;cin>>a>>b;

	int ans=a*b/gcd(a,b);
	cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 3600
#include<cstdio>

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

    int total = 0;
    int sum = 0;
    bool flag = false;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N-i; j++) {
            for(int k = 0; k <= N-j; k++) {
                total = i+j+k;
                sum = 10000*i+5000*j+1000*k;
                if(total == N && sum == Y) {
                    printf("%d %d %d\n",i,j,k);
                    flag = true;
                    break;
                }
            }
            if(flag) { break; }
        }
        if(flag) { break; }
    }
    if(sum != Y) { printf("%d %d %d\n",-1,-1,-1); }
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

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

        int N = Integer.parseInt(sc.nextLine());
        Set<Integer> set = new TreeSet<>();
        for (int i = 0; i < N; i++) {
            set.add(Integer.parseInt(sc.nextLine()));
        }

        int ans = 0;
        int before = 0;
        for (Integer current : set) {
            if (before < current) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
import math
A, B, C = map(int, input().split())
l = [A,B,C]

max_index = l.index(max(l))
if max_index == 0:
    large = B * C * math.floor(A/2)
elif max_index == 1:
    large = C * A * math.floor(B/2)
else:
    large = A * B * math.floor(C/2)
ans = (A*B*C - large) - large
# ans = large - (A*B*C - large)
print(ans)




Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad
import Data.Int (Int64)
import Data.List (foldl')
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  s <- BS.getLine
  let bw = length $ filter (\(x,y) -> x /= y) $ zip (BS.unpack s) (cycle "01")
      wb = BS.length s - bw
  print (min bw wb)


Measured memory_bytes: 1148
import math

n=int(input())

XY=[]

for i in range(n):
    x,y=map(int,input().split())
    XY.append([x,y])

v=[]

for i in range(n):
    for j in range(n):
        if j!=i:
            v.append([XY[i][0]-XY[j][0],XY[i][1]-XY[j][1]])


c=0
for vx,vy in v:
    cv=0
    for i in range(n):
        for j in range(n):
            if j!=i and [XY[i][0]-XY[j][0],XY[i][1]-XY[j][1]]==[vx,vy]:
                cv+=1
    c=max(cv,c)

print(n-c)

Measured memory_bytes: 43244
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;
 
int main() {
    int n;
    cin >> n;
    priority_queue<ll, vector<ll>, greater<ll>> m;

    rep(i,n){
        ll tmp;
        cin >> tmp;
        m.push(tmp);
    }
    #if 1
    while(1) {
        
        ll min = m.top();m.pop();
        ll top = m.top();m.pop();
        ll d = top%min; 
        if(d!=0) {
            m.push(min);
            m.push(d);
        } else {
            m.push(min);
        }
        if(m.size() == 1) { break; }
    }
    #else 
    cout << m.top() << endl;
    #endif
    cout << m.top() << endl;
}



Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>

#define INF 1000000000;
#define MOD 1000000007;
typedef long long ll;
using namespace std;

ll fn(ll m, ll a) {
    return m % a;
}

int main()
{
    string s; cin >> s;
    int option = count(s.begin(), s.end(), 'o');
    cout << 700 + option * 100 << endl;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
s = ['.'*(w+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(w+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      yi = i + dy[k]
      xi = j + dx[k]
      if s[i][j] == '#' and s[yi][xi] == '.':
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')


Measured memory_bytes: 3064
#include <cstdio>
#include <unordered_map>
#include <vector>
const int HASH = 131;
const int MAXN = 5005;
const int MOD = 1e9+7;
char S[MAXN];
int H[MAXN];
int N, size;

std::unordered_map<int, std::vector<int>> D;

bool compare(int a, int b) {
  for (int k = 0; k < size; ++k) {
    if (S[a-k] != S[b-k]) return false;
  }
  return true;
}

bool matches(int sum, int cur) {
  for (int pos: D.at(sum)) {
    if (pos + size > cur) break;
    if (compare(pos, cur)) {
      return true;
    }
  }
  return false;
}

bool find() {
  D.clear();
  D.reserve(N);

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum = (1LL * HASH * sum + S[i]) % MOD;
    if (i >= size) {
      int old = 1LL * H[size] * S[i-size] % MOD;
      sum = (sum - old + MOD) % MOD;
    }
    if (i+1 >= size) {
      if (D.count(sum) && matches(sum, i)) {
        return true;
      }
      D[sum].push_back(i);
    }
  }
  return false;
}

void init() {
  H[0] = 1;
  for (int i = 1; i <= N; ++i) {
    H[i] = 1LL * H[i-1] * HASH % MOD;
  }
}

int solve() {
  int lo = 0;
  int hi = N/2;
  while (lo < hi) {
    size = (lo + hi + 1) / 2;
    if (find()) {
      lo = size;
    } else {
      hi = size-1;
    }
  }
  return lo;
}

int main() {
  scanf(" %d%s", &N, S);
  init();
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 656
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using interval = pair<int, int>;

int main() {
    int _, m; cin >> _ >> m;
    vector<pair<int, int>> jobs(m);
    for (auto &p: jobs) cin >> p.first >> p.second;
    sort(jobs.begin(), jobs.end(), [](interval &a, interval &b) {
        return a.second < b.second;
    });
    int cnt = 0, lst = 0;
    for (auto &p: jobs) if (p.first >= lst) lst = p.second, cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i = 0; i < m; i++){
    cin >> x[i];
    }
   if(n >= m){
       cout << 0 << endl;
       return 0;
   }
    sort(x.begin(),x.end());
    int sum = abs(x[m - 1] - x[0]);
    vector<int> def(m,0);
    for(int i = 0; i < m - 1; i++){
       def[i] = abs(x[i + 1] - x[i]);
    }
    sort(def.begin(),def.end());
    reverse(def.begin(),def.end());
    for(int i = 0; i < n - 1; i++){
        sum -= def[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
from itertools import *
from heapq import *

def solve(H, W, grid):
  goal = (H-1, W-1)
  fixed = set()
  candicates = [(grid[0,0], (0, 0))]
  while 1:
    dist, p = heappop(candicates)
    if p == goal:
      return dist
    if p in fixed:
      continue
    fixed.add(p)
    for i in range(2):
      p1 = p[0]+i, p[1]+(1-i)
      if not (p1[0]<H and p1[1]<W) or p1 in fixed:
        continue
      x, y = p
      x1, y1 = p1
      heappush(candicates, (dist+(grid[p1] & ~grid[p]), p1))
  return None

H, W = map(int, input().split())
grid = {(i,j): int(c=="#") for i in range(H) for j, c in enumerate(input())}

print(solve(H, W, grid))

Measured memory_bytes: 5368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Sales sales = new Sales();
		String input;
		while((input = br.readLine()) != null){
			String[] str = input.split(",");
			sales.addSales(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
		}
		sales.printSalesAndAvgSold();
	}
}

class Sales{
	private long numItem;
	private long sumSales;
	private long sumItemsSold;
	
	Sales(){
		numItem = 0;
		sumSales = 0;
		sumItemsSold = 0;
	}
	
	public void addSales(int price, int numSales){
		numItem++;
		long sales = price * numSales;
		sumSales += sales;
		sumItemsSold += numSales;
	}
	
	public void printSalesAndAvgSold(){
		System.out.println(sumSales);
		long avgSold = Math.round((double)sumItemsSold / (double)numItem);
		System.out.println(avgSold);
	}
}

Measured memory_bytes: 9364
#include<iostream>
#include<string>

int main(){
    std::string N;
    std::cin >> N;
    if(N[0] == '9' || N[1] == '9'){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c,ans;
    string s,t,q;
    cin>>a>>b>>c;
    ans=a*100+b*10+c;
    if(ans%4==0) cout<<"YES\n";
    else cout<<"NO\n";
    return(0);
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll tmp[M],ar[M];

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

	ll n,k,i,j,l,r,cnt;

	cin >> n >> k;
	for(i=1;i<=n;++i)
		cin >> ar[i];
	for(i=1;i<=k;++i)
	{
		for(j=1;j<=n;++j)
		{
			l = max(1ll,j-ar[j]);
			tmp[l] += 1;
			r = min(n,j+ar[j]);
			tmp[r+1] -= 1;
		}
		ll cnt = 0;
		for(j=1;j<=n;++j)
		{
			tmp[j] += tmp[j-1];
			if(tmp[j] == ar[j] || tmp[j] >= n)
				cnt++; 
			ar[j] = tmp[j];
		}
		if(cnt == n)
			break;
		for(j=1;j<=n;++j)
			tmp[j] = 0;
	}

	for(i=1;i<=n;++i)
		cout << min(n,ar[i]) << " ";
	cout << "\n";
}



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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec(N, vector<int>(2));
  for(int i=0; i<N; i++){
    cin >> vec.at(i).at(0);
    vec.at(i).at(1) = i+1;
  }
  sort(vec.begin(), vec.end());
  for(int i=0; i<N; i++){
    cout << vec.at(i).at(1);
    cout << " ";
  }

  return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
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; }

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

const int INF = 1001001001;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a-2*b, 0) << endl;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] c = new int[(int) 1e6+1];
		
		/*
		 * a * b + c = n
		 * n / b = a ... c
		 */
		long ans = 0;
		for( int i=1 ; i<n ; i++ ) {
			int n2 = n/i + ( n%i != 0 ? 1 : 0) - 1;
			ans+= n2;
		}
		
		System.out.println(ans);
		

	}

}



Measured memory_bytes: 39600
function Main(input) {
  input = input.split("\n");
  const changeInt = (n) => {
    return parseInt(n, 10);
  };
  const [N,W] = input[0].split(' ').map(changeInt);
  const wv = [];
  for (var i = 0; i < N; i++) {
    wv.push(input[i + 1].split(' ').map(changeInt));
  }
 console.log(knapsack(N,W,wv));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function knapsack(N,W,wv) {
  const dp = Array(N+1).fill(0).map( n =>Array(W+1).fill(0) );
  for (var i = 0; i < N; i++) {
    for (w = 0; w <= W; w++) {
      if (w >= wv[i][0]) {
        dp[i+1][w] = Math.max(dp[i][w - wv[i][0]] + wv[i][1],dp[i][w]);
      } else {
        dp[i+1][w] = dp[i][w];
      }
    }
  }
  return dp[N][W];
}


Measured memory_bytes: 163852
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=2e3+2;
int n,k,res;
struct Edge{
	int to,nxt;
};
Edge edge[maxn<<1];
int cnt,head[maxn];
void addedge(int u,int v){
	cnt++;
	edge[cnt].to=v;
	edge[cnt].nxt=head[u];
	head[u]=cnt;
}
int dfs(int u,int fa,int dep){
	int sum=1;
	if (dep!=k/2)
		for (int i=head[u];~i;i=edge[i].nxt){
			int v=edge[i].to;
			if (v==fa) continue;
			sum+=dfs(v,u,dep+1);
		}
	return sum;
}
void init(){
	cnt=0;
	memset(head,-1,sizeof(head));
}
int main(){
	init();
	scanf("%d%d",&n,&k);
	for (int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v);
		addedge(v,u);
	}
	if (k&1)
		for (int u=1;u<=n;u++)
			for (int i=head[u];~i;i=edge[i].nxt){
				int v=edge[i].to;
				res=max(res,dfs(u,v,0)+dfs(v,u,0));
			}
	else
		for (int u=1;u<=n;u++)
			res=max(res,dfs(u,-1,0));
	printf("%d",n-res);
	return 0;
}

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();
		int x[] = new int[n];
		
		for(int i = 0; i < n; i++){
			x[i] = sc.nextInt();
		}
		for(int i = n-1; i >= 0; i--){
			System.out.print(x[i]);
			if(i != 0) System.out.print(" ");
			else System.out.println();
		}
	}
}


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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  int s, t;
  s = a.size();
  t = b.size();
  if (a[s-1] == b[0] && b[t-1] == c[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}

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

using namespace std;
const int N = 2002, mod = 1e9 + 7;
int fact[N * 2];

int fastpower(int b, int p) {
    int res = 1;
    int v = b;
    while (p) {
        if (p & 1) res = (1ll * res * v) % mod;
        p >>= 1;
        v = (1ll * v * v) % mod;
    }
    return res;
}

void pre() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i < N * 2; ++i) {
        fact[i] = (1ll * i * fact[i - 1]) % mod;
    }
}

int ncr(int n, int r) {
    if (r > n || n < 0 || r < 0) return 0;
    if (n == r || r == 0) return 1;
    int res = fact[n];
    res = (1ll * res * fastpower(fact[r], mod - 2)) % mod;
    res = (1ll * res * fastpower(fact[n - r], mod - 2)) % mod;
    return res;
}

int main() {
    //freopen("in.txt", "rt", stdin);
    pre();
    int n, k;
    scanf("%d %d", &n, &k);
    long long v;
    for (int i = 1; i <= k; ++i) {
        int l = k - i;
        v = ncr(l + i - 1, i - 1);
        v = (1ll * v * ncr(n - k + i - (i - 1), i)) % mod;
        printf("%lld\n", v);
    }
}

Measured memory_bytes: 256
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(lis[int(input())-1])

Measured memory_bytes: 38384
n, m = [int(x) for x in input().split()]
L = []
c=0
for _ in range(n):
    c += 1
    a = int(input())
    L.append((c,a))

V = [0] * (n+1)
for _ in range(m):
    b = int(input())
    for i,a in L:
        if a <=b:
            V[i] += 1
            break
v = max(V)
t = V.index(v)

print(t)





Measured memory_bytes: 5620
// 071-c
// Sortして、最大が4以上なら正方形にし、そうでなければ2以上のもののうち大きい2つを掛け合わせる


#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll N,A[100007],c=0,tate,yoko;cin >> N;
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  for(int i=N-1;i>=0;i--){
    if(A[i]==A[i-1]){
      i--;
      if(c==0){
        tate=A[i];
      }
      else{
        yoko=A[i];
        cout << tate*yoko << endl;
        return 0;
      }
      c++;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll A;
	double B;
	cin >> A >> B;

	ll C = (ll)(B * 100.0+0.01);
	//cout << C << endl;
	ll ans = A * C / 100;
	cout << ans << endl;
}


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

using namespace std;

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

const int MAXN = 205000;
const int INF = 1e9;

int n, m;
vector<int> g[MAXN];
int from[MAXN], to[MAXN], color[MAXN];

class Dsu {
private:
    vector<int> st;
    int n;
public:
    void init(int sz) {
        n = sz;
        st.assign(n, 0);
        for (int i = 0; i < n; i++) {
            st[i] = i;
        }
    }
    int getSet(int x) {
        if (st[x] == x)
            return x;
        st[x] = getSet(st[x]);
        return st[x];
    }
    void unite(int a, int b) {
        a = getSet(a); b = getSet(b);
        if (rand() & 1)
            swap(a, b);
        st[a] = b;
    }
};

Dsu dsu;
set <int> comps[MAXN];
queue <int> q;
int dist[MAXN];
bool processed[MAXN];

void process(int v, int curDist) {
    if (processed[v]) {
        return;
    }
    processed[v] = true;
    for (int idx : g[v]) {
        int st = dsu.getSet(idx);
        if (dist[st] != INF) {
            continue;
        }
        dist[st] = curDist + 1;
        q.push(st);
    }
}

int main() {

    scanf("%d %d", &n, &m);

    dsu.init(m);

    for (int i = 0; i < m; i++) {
        scanf("%d %d %d", &from[i], &to[i], &color[i]); 
        from[i]--; to[i]--;
        g[from[i]].push_back(i);
        g[to[i]].push_back(i);
    }

    for (int i = 0; i < n; i++) {
        map <int, int> prev;
        for (int idx : g[i]) {
            if (prev.count(color[idx])) {
                dsu.unite(idx, prev[color[idx]]);
            }
            prev[color[idx]] = idx;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int idx : g[i]) {
            comps[dsu.getSet(idx)].insert(i);
        }
    }

    for (int i = 0; i < m; i++) {
        dist[i] = INF;
    }
    process(0, 0);

    while (!q.empty()) {
        int curSt = q.front();
        q.pop();

        for (int v : comps[curSt]) {
            process(v, dist[curSt]);
        }
    }

    int ans = n + 10;
    for (int i = 0; i < m; i++) {
        int st = dsu.getSet(i);

        if (comps[st].count(n - 1)) {
            ans = min(ans, dist[st]);
        }
    }

    if (ans > n)
        ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 42112
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
const int N=8000005,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int qx[N],qy[N],qd[N],b,e;
int main()
{
	ios::sync_with_stdio(false);
	int n,m,k,bx,by,ex,ey;
	cin>>n>>m>>k>>bx>>by>>ex>>ey;
	vector<vector<char>>s(n,vector<char>(m,'.'));
	vector<vector<int>>d[4];
	vector<int>zh(m,1e9);
	for(int i=0;i<4;i++)
		for(int j=0;j<n;j++)
			d[i].push_back(zh);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>s[i][j];
	bx--,by--,ex--,ey--;
	for(int i=0;i<4;i++)
	{
		d[i][bx][by]=0;
		qx[e]=bx,qy[e]=by,qd[e]=i,e++;
	}
	while(b<e)
	{
		int x=qx[b],y=qy[b],dd=qd[b];b++;
		for(int i=0;i<4;i++)
			d[i][x][y]=d[dd][x][y];
		if(x==ex&&y==ey)
			break;
		for(int i=0;i<4;i++)
		{
			int zh=0,kx=x,ky=y;
			while(1)
			{
				kx+=dx[i],ky+=dy[i],zh++;
				if(kx<0||kx>=n||ky<0||ky>=m||s[kx][ky]=='@')
					break;
				if(d[i][kx][ky]>d[0][x][y]+1)
				{
					d[i][kx][ky]=d[0][x][y]+1;
					qx[e]=kx,qy[e]=ky,qd[e]=i,e++;
				}
				else if(d[i][kx][ky]<=d[0][x][y])
					break;
				if(zh==k)
					break;
			}
		}
	}
	printf("%d\n",d[0][ex][ey]==1e9?-1:d[0][ex][ey]);
	return 0;
}


Measured memory_bytes: 32472
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int x = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(a;a<=b;a++){
		if(c%a==0){
			x++;
		}
	}
	printf("%d\n",x);
	
	return 0;
}

Measured memory_bytes: 596
N,W = map(int,input().split())

from collections import defaultdict
List = []
dp = []*(N+1)
for i in range(N+1):
    dp.append(defaultdict(lambda : -float("inf")))
for i in range(N+1):
    dp[i][0] = 0
#print(dp)

for i in range(N):
    w,v = map(int,input().split())
    List.append([w,v])

for i in range(N):
    w,v = List[i]
    for j in list(dp[i]):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j+w <= W:
            dp[i+1][j+w] = max(dp[i][j+w], dp[i][j]+v)
ans = -float("inf")
for i in dp[N]:
    ans = max(ans,dp[N][i])
    
print(ans)

Measured memory_bytes: 53104
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


class Dinic{
private:
    struct edge{int to,cap,rev;};
    vector<vector<edge> > g;
    vector<int> level,iter;
    int n;

    void bfs(int s){//sからの最短距離を計算する
        level = vector<int>(n,-1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int i = 0; i < g[v].size(); i++){
                edge &e = g[v][i];
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f){//増加パスを探す
        if(v == t)return f;
        for(int &i = iter[v]; i < g[v].size(); i++){
            edge &e = g[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int d = dfs(e.to, t, min(f,e.cap));
                if(d > 0){
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:

    Dinic(){}
    Dinic(int size){
        n = size;
        g = vector<vector<edge> >(n);
    }

    void add_edge(int from, int to, int cap){
        g[from].push_back((edge){to,cap,g[to].size()});
        g[to].push_back((edge){from,0,g[from].size()-1});
    }

    int max_flow(int s, int t){//sからtへの最大流  O(EV^2)
        int flow = 0;
        while(1){
            bfs(s);
            if(level[t] < 0)return flow;
            iter = vector<int>(n,0);
            int f;
            while((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }

};

void GRL6a(){
    int n,m;
    cin >> n >> m;
    Dinic dinic(n);
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        dinic.add_edge(a,b,c);
    }
    cout << dinic.max_flow(0,n-1) << endl;
}
signed main(void) {
    GRL6a();
}



Measured memory_bytes: 3264