akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){

  int i,j,k,n,v,A[1001];
  
  scanf("%d", &n );

  for ( i = 0 ; i < n ; i++ ){
    scanf("%d", &A[i] );
  }
    
  for ( i = 0 ; i < n ; i++ ){

    v = A[i];
    
    for ( j = 0 ; j < i ; j++ ){
      if ( v <= A[j] ){
	for ( k = i ; k > j ; k-- ){
	  A[k] = A[ k - 1 ];
	}
	A[j] = v;
	break;
      }
    }

    for ( j = 0 ; j < n ; j++ ){
      if ( j == n - 1 ) {
	printf("%d\n", A[j] );
      } else {
	printf("%d ", A[j] );
      } 
    }

  }

  return 0;

}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
const int c = 300000;
int main(){
   int n,b[c]={},w[c]={},ans=c;
   string s;
   cin >> n >> s;
   for(int i=0;i<n;i++){
       int flag = 0,flag1=0;
       if(s[i]=='#') flag++;
       b[i+1] = b[i] + flag;
       if(s[n-i-1]=='.') flag1++;
       w[i+1] = w[i] + flag1;
   }
   reverse(w,w+n+1);
   for(int i=0;i<=n;i++) ans = min(ans,b[i]+w[i]);
   cout << ans << endl;
}

Measured memory_bytes: 2948
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	listA := make([]int, n+1)
	listB := make([]int, n)
	for i := 0; i < n+1; i++ {
		fmt.Scan(&listA[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&listB[i])
	}

	count := 0
	for i := 0; i < n; i++ {
		if listA[i] <= listB[i] {
			count += listA[i]
			if listA[i+1] >= listB[i]-listA[i] {
				count += listB[i] - listA[i]
				listA[i+1] -= listB[i] - listA[i]
			} else {
				count += listA[i+1]
				listA[i+1] = 0
			}
		} else {
			count += listB[i]
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 5504
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double lb; 

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


int main() {
    ll x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll dx = x2-x1;
    ll dy = y2-y1;
    cout << x2-dy << " " << y2+dx << " " << x1-dy << " " << y1+dx << endl;

}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns     #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiWayIf       #-}
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State
import           Control.Monad.Trans.State
import           Data.Array.IArray
import           Data.Array.ST
import           Data.Array.Unboxed        (UArray)
import qualified Data.Array.Unboxed        as U
import           Data.Bits
import           Data.ByteString.Char8     (ByteString)
import qualified Data.ByteString.Char8     as BS
import           Data.Char
import           Data.Graph
import           Data.Int                  (Int64)
import           Data.List
import           Data.Maybe
import           Data.Proxy
import           Data.Sequence             (Seq, (<|), (><), (|>))
import qualified Data.Sequence             as Seq
import qualified Data.Set                  as S
import           Data.STRef
import qualified Data.Vector               as V
import qualified Data.Vector.Unboxed       as VU
import           Numeric

main :: IO ()
main = do
  [n,k] <- readLnAsListWith unconsInt
  aary <- getAsIntArray1Dr n
  forM_ [k+1..n] $ \i -> putStrLn $ if solve aary k i then "Yes" else "No"


solve :: UArray Int Int -> Int -> Int -> Bool
solve ary k i = ary ! (i-k) < ary ! i


getAsInt :: IO [Int]
getAsInt =  unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getAsIntLine :: Int -> IO [[Int]]
getAsIntLine n = replicateM n getAsInt

getAsIntArray1Dr :: Int -> IO (UArray Int Int)
getAsIntArray1Dr n = U.listArray (1,n) <$> getAsInt



-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

unconsInteger :: StateT BS.ByteString Maybe Integer
unconsInteger = StateT $ BS.readInteger . BS.dropWhile isSpace

-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith st = unfoldr (runStateT st) <$> BS.getLine

-- for unboxed vector
readLnAsUVecNWith :: VU.Unbox a => Int -> StateT BS.ByteString Maybe a -> IO (VU.Vector a)
readLnAsUVecNWith !n !st = VU.unfoldrN n (runStateT st) <$> BS.getLine

-- for boxed vector
readLnAsVecNWith :: Int -> StateT BS.ByteString Maybe a -> IO (V.Vector a)
readLnAsVecNWith !n !st = V.unfoldrN n (runStateT st) <$> BS.getLine

getAsString :: IO [String]
getAsString = map BS.unpack . BS.words <$> BS.getLine

getAsCharArray1DWithLength :: IO (Int, UArray Int Char)
getAsCharArray1DWithLength = BS.getLine >>= \ !cs ->
  let !n = BS.length cs
      !ary = (U.listArray (1,n) $ unfoldr BS.uncons cs) :: UArray Int Char
  in return (n, ary)

-- n: number of lines
-- m: number of chars per a line
getAsCharArray2D :: Int -> Int -> IO (UArray (Int,Int) Char)
getAsCharArray2D !n !m = U.listArray ((1,1),(n,m)) . unfoldr BS.uncons . BS.concat <$> replicateM n BS.getLine


Measured memory_bytes: 11284
import copy
s = input()
t = input()
flag = True
listed_s = list(s)
swaped_s = list(s)
for i in range(len(s)):
    if ("".join(listed_s) == t) and (flag):
        flag = False
        print("Yes")
    swaped_s = [listed_s[-1] for i in range(len(s))]
    for i in range(len(s) - 1):
        swaped_s[i + 1] = listed_s[i]
    listed_s = copy.copy(swaped_s)
    if ("".join(listed_s) == t) and (flag):
        flag = False
        print("Yes")

if flag:
    print("No")


Measured memory_bytes: 3444
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy";
  }else if(s=="Cloudy"){
    cout<<"Rainy";
  }else{
    cout<<"Sunny";
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------
// // [gcd]
// template<class T> T gcd(T a,T b)
// {if (a < b) swap(a,b);return b ? gcd(b, a % b) : a;}
// template<class T> T lcm(const T a, const T b)
// {return (a * b / gcd(a, b));}

void Main(){
  int n;
  cin>>n;
  vl a(n);
  cin>>a;
  ll ans = a[0];
  rep(i,n){
    ans = __gcd(ans,a[i]);
  }
  cout<<ans<<endl;
} int main(int argc,char** argv)
{fastio; myio; Main();}


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

long long a[222222];

int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    for(int i=0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }


    long long mi = 1e16;
    long long head = 0;
    for(int i=0; i < n-1; i++){
        head += a[i];
        long long tail = sum - head;
        mi = min(abs(head - tail), mi);
    }

    cout << mi << endl;
    return 0;
}


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

int main(){
  int N,result=0;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  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(L[i]<L[j]+L[k]&&L[j]<L[i]+L[k]&&L[k]<L[i]+L[j]){
          result++;
        }
      }
    }
  }
  cout<<result;
}

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

int main(){
	int a, b, c, d, e, f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double x, y;
		y = 1.0*(d*c-a*f)/(d*b-a*e);
		x = 1.0*(e*c-b*f)/(e*a-b*d);
		if(fabs(x)<0.0005) x = 0.0;
		if(fabs(y)<0.0005) y = 0.0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 0
#include "stdio.h"


int main()
{
    int N, a, A[1000];
    scanf("%d", &N);
    for (a = 0; a<N; a++)
        scanf("%d\n", &A[a]);

    for (a = 0; a < N - 1; a++)
        printf("%d ", A[a]);

    printf("%d\n", A[N-1]);

    int j;
    for (int i = 1; i < N; i++) {
        int v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
    

    for (j = 0; j < N - 1; j++)
        printf("%d ", A[j]);

    printf("%d\n", A[N - 1]);
    }

    return 0;
}

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

int main(){
	int myc1, myc2, yourc;
	while(cin >>myc1 >>myc2 >>yourc){
		if(myc1 == EOF) break;
		int mysum = myc1 + myc2, cnt = 0;
		for(int i = 1; i < 10; i++){
			if(i == myc1 || i == myc2 || i == yourc) continue;
			if(i + mysum <= 20) cnt++;
		}
		if(cnt >= 4) cout <<"YES" <<endl;
		else cout <<"NO" <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S; cin >> S;
	if (S[0] != 'A' || S[1] == 'C') {
		cout << "WA" << endl;
		return 0;
	}
	int cnt = 0;
	REP(i, 2, S.length() - 2) {
		if (S[i] == 'C') cnt++;
	}
	if (cnt > 1 || cnt == 0) {
		cout << "WA" << endl;
		return 0;
	}
	REP(i, 1, (int)S.length() - 1) {
		if (S[i] == 'C') continue;
		if (S[i] < 'a') {
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC" << endl;

    return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<int> row(H,0);
  vector<int> col(W,0);
  vector<string> V(H);
  for (int i = 0; i < H; i++) 
    cin >> V.at(i);
  for (int j = 0; j < H; j++) {
    for (int j2 = 0; j2 < W; j2++){
      if (V.at(j).at(j2) == '#') {
        row.at(j) = 1;
        col.at(j2) = 1;
      }
    }
  }
  for (int k = 0; k < H; k++) {
    if (row.at(k) == 1) {
      for(int k2 = 0; k2 < W; k2++) {
        if (col.at(k2) == 1)
          cout << V.at(k).at(k2);
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    vector<int> a(5);
    cin >> a;
    int k;
    cin >> k;
    if (a[4] - a[0] > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return (0^_^0);
}



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

//dp[i] => true if the first player wins , false otherwise

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    for(int &x : a)
        scanf("%d",&x);
    
    bool dp[k+1];
    memset(dp,false,sizeof dp);
    for(int stones = 0 ;stones <= k;stones++)
    {
        for(int i = 0;i<n;i++){
            if(stones >= a[i] && !dp[stones - a[i]])
                   dp[stones] = true;
        }
    }
    puts(dp[k]?"First":"Second");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n, m;
ll a[100], b[100];
ll c[100], d[100];

ll calc(ll a, ll b, ll c, ll d) {
	return abs(a - c) + abs(b - d);
}

int main() {
	cin >> n >> m;
	REP(i, n) cin >> a[i] >> b[i];
	REP(i, m) cin >> c[i] >> d[i];
	REP(i, n) {
		ll ans = -1;
		ll num = INF;
		REP(j, m) {
			if (num > calc(a[i], b[i], c[j], d[j])) {
				ans = j + 1;
				num = calc(a[i], b[i], c[j], d[j]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
//Coronados de gloria vivamos, o juremos con gloria morir
#include <bits/stdc++.h>

using namespace std;

#ifdef ACMTUYO
#define mine(x) x
#else
#define mine(x)
#endif


#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n);i++)
#define dforn(i,n) for(int i=(int)((n)-1);i>=0;i--)
#define dforsn(i,s,n) for(int i=(int)((n)-1);i>=(int)(s);i--)
#define all(c) begin(c), end(c)
#define esta(x,c) ((c).find(x) != end(c))


#define wbe(f, c, as...) f(all(c), ##as)
#define wbeb(f, c, d, as...) f(all(c), begin(d), ##as)
#define L(r, as...) [&](as){return r;}

#define LEA mine(freopen("in.txt", "r", stdin))

#define dbgi(a) << #a << " = " << (a) <<
#define dbg1(a, z...) 	dbgi(a) ""
#define dbg2(a, z...)  	dbgi(a) ", " dbg1(z)
#define dbg3(a, z...)  	dbgi(a) ", " dbg2(z)
#define dbg4(a, z...)  	dbgi(a) ", " dbg3(z)
#define dbg5(a, z...)   dbgi(a) ", " dbg4(z)

#define dbgx(v1, v2, v3, v4, v5, v6, z...) v6
#define dbg(z...)  cerr dbgx(z, dbg5(z), dbg4(z), dbg3(z), dbg2(z), dbg1(z)) << endl;

#define raya mine(cerr << "----------" << endl)

// TYPEDEFS
typedef long long tint;
typedef vector<int> vint;
typedef vector<vector<int>> grint;
typedef pair<int,int> pint;
typedef long double tdbl;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

const double PI=acos(-1.0);

int main(int argc, char **argv) {
	//        LEA;
	ios_base::sync_with_stdio(0);

	vint a(3);

	cin >> a[0] >> a[1] >> a[2];

	sort(all(a));

	cout << (a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,ans=0,x;
  cin>>x;//读入
  n=ceil(x/11.0);
  //此处的'ceil'为向上取整符，而为了防止括号内自动向下取整，
  //需要加上.0来强制转换为浮点型
  ans=ceil(x/11.0)*2;
  //因为每一大轮其实是两轮，所以要乘2
  if(n*11-x>=5)//如果可以省略最后掷的五分
    ans--;//答案减一
  cout<<ans<<endl;//输出
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    t,x = map(int, input().split())
    print(t/x)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
D,G = map(int,input().split())
P = []
C = []
for i in range(D):
	p,c = map(int,input().split())
	P.append(p)
	C.append(c)

ans = (float('inf'))

for bit in range(2**D):
	wa = 0
	cnt = 0
	for i in range(D):
		if (bit & (1<<i)):
			wa += (i+1)*100*P[i]+C[i]
			cnt += P[i]
		
	for i in range(D-1,-1,-1):
		if wa >= G:
			break
		if bit & (1<<i):
			continue
		s = (i+1)*100
		need = (G-wa+s-1)//s
		wa += min(need,P[i])*s
		cnt += min(need,P[i])

	if wa >= G:
		ans  = min(ans,cnt)

print(ans)

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

const int maxn = 16;
int n;

vector<pair<int,int>> v[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        int ai; cin >> ai;
        while (ai--) {
            int x, y; cin >> x >> y;
            x--;
            v[i].push_back({x,y});
        }
    }
    int ans = 0;
    for (int mask = 0; mask < (1<<n); mask++) {
        vector<bool> honest(n);
        int num = 0;
        for (int i = 0; i < n; i++) {
            honest[i] = mask & (1<<i);
            if (honest[i]) num++;
        }
        bool poss = true;
        for (int i = 0; i < n; i++) {
            for (auto p: v[i]) {
                int x = p.first;
                bool y = (bool)p.second;
                if (honest[i] && honest[x] != y) {
                    poss = false;
                    break;
                }
            }
        }
        if (poss) {
            ans = max(ans,num);
        }
    }
    cout << ans << '\n';
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

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

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

const int max_v=100000;
vector<int> graph[max_v];
bool used_v[max_v];
map<int,bool> used_e[max_v];
int ord[max_v],lowlink[max_v];
vector<pii> bridges;

void dfs(int v,int &k){
    used_v[v]=true;
    ord[v]=lowlink[v]=k++;
    for(int u:graph[v]){
        if(!used_v[u]){
            used_e[v][u]=true;
            dfs(u,k);
            lowlink[v]=min(lowlink[v],lowlink[u]);
            if(ord[v]<lowlink[u]) bridges.push_back(make_pair(min(v,u),max(v,u)));
        }else if(!used_e[u][v]) lowlink[v]=min(lowlink[v],ord[u]);
    }
}

void solve(){
    int v,e;
    cin >> v >> e;
    
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }
    
    int k=0;
    dfs(0,k);
    
    sort(bridges.begin(),bridges.end());
    
    for(auto &e:bridges) cout << e.first << " " << e.second << endl;
}

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

Measured memory_bytes: 14284
#include<random>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<fstream>

using namespace std;
typedef long long ll;
#define MP make_pair
#define mod 1000000007

int main(void) {
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)cout<<"Yes\n";
    else cout<<"No\n";
    
    
    return 0;
}

Measured memory_bytes: 3592
n = int(input())
s = input()
ans = 0

for i in range(1,n):
    x = ''.join(set(s[:i]))
    y = ''.join(set(s[i:]))
    z = 0
    for j in y:
        if j in x:
            z += 1
    if z > ans:
        ans = z
        
print(ans)

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 1e2 + 5;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen("VLJUM.INP", "r")){
                freopen("VLJUM.INP", "r", stdin);
                freopen("VLJUM.OUT", "w", stdout);
        }
        ll n, cnt = 0;
        cin >> n;
        priority_queue<ll, vector<ll>, greater<ll>> pq;
        for (int i = 1; i <= 9; i++){
                pq.push(i);
        }
        while (true){
                ll now = pq.top();
                pq.pop();
                cnt++;
                if (cnt == n) {
                        cout << now;
                        return 0;
                }
                for (int i = 0; i < 10; i++){
                        if (abs((now % 10) - i) <= 1){
                                pq.push(now * 10 + i);
                        }
                }
        }
}
/*
*/


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int co=0;
    for(int i=0;i<str.size();i++)
    {
    if(str[i]=='1')co++;
    }
    cout<<co<<endl;
    return 0;
}


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

void fnInsertionSort(vector<int> &argviSort, int argiGap, int &argiSortCnt)
{
  for (int ixSorting = argiGap; ixSorting < argviSort.size() ; ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - argiGap;

    while (ixSorted >= 0              &&
           iTarget < argviSort[ixSorted])
    {
      argviSort[ixSorted + argiGap] = argviSort[ixSorted];
      ixSorted -= argiGap;

      argiSortCnt++;
    }
    argviSort[ixSorted + argiGap] = iTarget;
  }
}

void fnShellSort(vector<int> &argviSort, vector<int> &argviGap, int &argiSortCnt)
{

  for (int iGap = 1; iGap <= argviSort.size(); iGap = 3 * iGap + 1)
    argviGap.push_back(iGap);
  
  for (int i = argviGap.size() - 1; i >= 0; i--)
    fnInsertionSort(argviSort, argviGap[i], argiSortCnt);
}

void fnOutput(const vector<int> &argviSort, const vector<int> &argviGap, int argiSortCnt)
{
  cout << argviGap.size() << endl;

  for (int i = argviGap.size() - 1; i >= 0; i--)
  {
    if (i != argviGap.size() - 1) cout << " ";
    cout << argviGap[i];
  }
  cout << endl;

  cout << argiSortCnt << endl;

  for (int i = 0; i < argviSort.size(); i++)
    cout << argviSort[i] << endl;
}

int main()
{
  vector<int> viSort;
  vector<int> viGap;
  int iSortCnt = 0;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnShellSort(viSort, viGap, iSortCnt);
  fnOutput(viSort, viGap, iSortCnt);

  return 0;
}

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

ll n,a,x,dp[55][2505],ans=0;
int main(){
	cin>>n>>a;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>x;
		for(int j=i-1;j>=0;j--){
			for(int k=2500;k>=0;k--){	
				if(k+x<=2500){
					dp[j+1][k+x]+=dp[j][k];
				}
			}
		}
	}
	for(int i=1;i<=n;i++){
		ans+=dp[i][a*i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4600
#include "bits/stdc++.h"
#define ll long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000000
using namespace std;
template <typename T>
inline T __lcm(T a, T b)
{
    return (a * b) / __gcd(a, b);
}

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<int> b;
    vector<int> r, g;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            r.push_back(i);
        }
        else if (s[i] == 'G')
        {
            g.push_back(i);
        }
        else
        {
            b.insert(i);
        }
    }
    ll ans = 0;
    for (int i = 0; i < r.size(); i++)
    {
        for (int j = 0; j < g.size(); j++)
        {
            int p, q;
            p = r[i];
            q = g[j];
            if (p > q)
            {
                swap(p, q);
            }
            ans += b.size();
            if (b.find(q + (q - p)) != b.end())
            {
                ans--;
            }
            if (b.find(p - (q - p)) != b.end())
            {
                ans--;
            }
            if ((q - p) > 1 && (q - p) % 2 == 0)
            {
                int temp = (p + q) / 2;
                if (b.find(temp) != b.end())
                {
                    ans--;
                }
            }
        }
    }
    printf("%lld\n", ans);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
#endif // ONLINE_JUDGE

    solve();
    return 0;
}


Measured memory_bytes: 3760
# include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N, Q;
	string S;
	char b;
	cin >> N >> Q >> S;
	int count = 0;
	vector<int> countlist(N+1);

	countlist.at(0) = 0;
	for (int i = 0; i < N-1; ++i)
	{
		b = S.at(i);
		if (b == 'A')
		{
			b = S.at(i + 1);
			if (b == 'C')
			{
				++count;
			}
		}
		countlist.at(i+1) = count;
	}

	for (int i = 0; i < Q; ++i)
	{
		int l_i, r_i;
		cin >> l_i >> r_i;
		cout << countlist.at(r_i - 1) - countlist.at(l_i - 1) << endl;
	}
}


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

int main() {
  int n,cnt=0;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  for(int i=0; i<n; i++) {
    if(v[v[i]-1]==i+1) {
      cnt++;
    }
  }
  cout << cnt/2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    lint n=s.length();
    lint ans=0;
    for(lint l=0,r=0;l<n;l=r){
        if(s.at(l)!='A'&&s.substr(l,2)!="BC"){
            r++;
            continue;
        }
        for(r=l;r<n;){
            if(s.at(r)=='A')r++;
            else if(s.substr(r,2)=="BC")r+=2;
            else break;
        }
        lint now=0;
        for(lint i=l;i<r;){
            if(s.at(i)=='A'){
                i++;
                now++;
            }
            else if(s.substr(i,2)=="BC"){
                i+=2;
                ans+=now;
            }
            else assert(false);
        }
    }
    std::cout<<ans<<'\n';
}


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

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

int main()
{
	int T[5];
	int min = 1000;
	int num;
	int ans = 0;

	for (int i = 0; i < 5; i++)
	{
		scanf("%d", &T[i]);
		if (T[i] % 10 != 0 && T[i] % 10 < min)
		{
			min = T[i]%10;
			num = i;
		}
	}

	//printf("-----%d %d--\n", min, num);

	for (int i = 0; i < 5; i++)
	{
		if (i != num)
		{
			if (T[i] % 10 != 0)
				ans += T[i] + (10 - T[i] % 10);
			else
				ans += T[i];
		}
		else
			ans += T[i];
	}

	printf("%d\n", ans);

}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc143/tasks/abc143_e
//warshall_floyd 2回
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using Mat = vector<vector<ll>>;
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M,L; cin>>N>>M>>L;
    Mat mat(N+1,vector<ll>(N+1,INT32_MAX));    
    REP(e,M){
        ll a,b,c;
        cin>>a>>b>>c;
        mat.at(a).at(b) = c;
        mat.at(b).at(a) = c;
    }
    ll Q; cin>>Q;
    vector<pair<ll,ll>> stq(Q); //s->t
    for(auto&& st:stq){
        cin>>st.first>>st.second;
    }

	auto warshall_floyd = [&](Mat& d) {
		REP(i, N+1)		   // 経由する頂点
			REP(j, N+1)	 // 開始頂点
				REP(k,N+1) // 終端
					d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	};
    warshall_floyd(mat);

    auto mat2=mat;
    for(auto&& y:mat2){
        for(auto&& x:y){
            if(x<=L) x=1;
            else x=INT32_MAX;
        }
    }
    warshall_floyd(mat2);

    for(const auto& st:stq){
        auto res=mat2.at(st.first).at(st.second);
        if(res>=INT32_MAX) cout<<-1<<endl;
        else cout<<res-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <functional>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <type_traits>
namespace loquat {
template <int MOD>
class modulus_integer {
public:
	typedef modulus_integer<MOD> self_type;
private:
	int m_value;
	static self_type unsafe_construct(int x) noexcept {
		self_type y;
		y.m_value = x;
		return y;
	}
public:
	modulus_integer() noexcept
		: m_value(0)
	{ }
	modulus_integer(int x) noexcept
		: m_value(x % MOD)
	{
		if(m_value < 0){ m_value += MOD; }
	}
	int operator*() const noexcept { return m_value; }
	self_type& operator=(const self_type& x) noexcept {
		m_value = x.m_value;
		return *this;
	}
	self_type operator*(const self_type& x) const noexcept {
		return unsafe_construct(
			static_cast<long long>(m_value) * x.m_value % MOD);
	}
	self_type& operator*=(const self_type& x) noexcept {
		return (*this = *this * x);
	}
};
template <int MOD>
inline std::ostream& operator<<(
	std::ostream& os, const modulus_integer<MOD>& x)
{
	os << *x;
	return os;
}
}
using namespace std;
static constexpr int MOD = 1000000007;
using mint = loquat::modulus_integer<MOD>;
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	array<int, 3> b = { 0, 0, 0 };
	mint answer = 1;
	for(int i = 0; i < n; ++i){
		const int x = a[i];
		int c = 0;
		for(int i = 0; i < 3; ++i){
			if(b[i] == x){ ++c; }
		}
		answer *= c;
		for(int i = 0; i < 3; ++i){
			if(b[i] == x){
				++b[i];
				break;
			}
		}
		sort(b.begin(), b.end());
	}
	cout << answer << endl;
	return 0;
}


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

set<int> getSet(int x) {
	set<int> ans;
	for(int i = 2; i*i <= x; i++) {
		if(x%i==0) {
			if(x == i*i) {
				ans.insert(i);
			} else {
				ans.insert(i);
				ans.insert(x/i);
			}
          while(x%i==0)
            x/=i;
		}
	}
    if(x > 1)
      ans.insert(x);
	return ans;
}

int main() 
{	
    int n, temp;
    cin >> n;
    int gcd;
    set<int> final;
    bool flag = true;
    cin >> gcd;
    for(int i = 1; i < n; i++) {
    	cin >> temp;
    	gcd = __gcd(temp, gcd);
    	if(flag) {
    		set<int> xyz = getSet(temp);
	    	for(auto v : xyz) {
	    		if(final.find(v) != final.end()) {
	    			flag = false;
	    		} else {
	    			final.insert(v);
	    		}
	    	}
    	}	
    }

    if(flag) {
    	cout << "pairwise coprime";
    } else if(gcd == 1) {
    	cout << "setwise coprime";
    } else {
    	cout << "not coprime";
    }

	return 0;
}


Measured memory_bytes: 7236
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


enum eps = 1e-9;

alias Point = Tuple!(double, "x", double, "y");

void main() {
    int N, K;
    scan(N, K);
    auto x = new double[](N);
    auto y = new double[](N);
    auto c = new double[](N);
    foreach (i ; 0 .. N) {
        scan(x[i], y[i], c[i]);
    }

    bool check(double t) {
        auto r = new double[](N);
        foreach (i ; 0 .. N) {
            r[i] = (t / c[i]);
        }

        Point[] tens;

        foreach (i ; 0 .. N) {
            tens ~= Point(x[i], y[i]);
            foreach (j ; i + 1 .. N) {
                auto d = hypot(x[i] - x[j], y[i] - y[j]);

                // ２つの円が交わらないとき
                if (r[i] + r[j] < d - eps) continue;
                // 一方の円がもう一方に完全に含まれている場合
                if (r[j] > r[i] + d + eps || r[j] < r[i] - d - eps) continue;

                // 交点が存在する場合
                auto theta = acos((r[i]*r[i] + d*d - r[j]*r[j]) / (2 * d * r[i]));
                auto v = Point((x[j] - x[i]) * r[i] / d, (y[j] - y[i]) * r[i] / d);
                auto p1 = Point(x[i] + v.x * cos(theta) - v.y * sin(theta),
                                y[i] + v.x * sin(theta) + v.y * cos(theta));
                auto p2 = Point(x[i] + v.x * cos(-theta) - v.y * sin(-theta),
                                y[i] + v.x * sin(-theta) + v.y * cos(-theta));
                tens ~= p1;
                tens ~= p2;
            }
        }

        int cmax;
        foreach (p ; tens) {
            int cnt;
            foreach (i ; 0 .. N) {
                if (hypot(p.x - x[i], p.y - y[i]) < r[i] + eps) {
                    cnt++;
                }
            }
            chmax(cmax, cnt);
        }

        return cmax >= K;
    }

    double ng = 0, ok = inf;
    foreach (i ; 0 .. 200) {
        auto mid = (ng + ok) / 2.0;
        (check(mid) ? ok : ng) = mid;
    }

    auto ans = ok;
    writefln("%.12f", ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
int A[1000][1000];
int D[1000][1000];
bool check[1000][1000];

struct bfs{
    int x, y, dist;
    bfs(int x, int y, int dist): x(x), y(y), dist(dist) {}
};

int main(){
    int H, W, K, si, sj;
    cin >> H >> W >> K;
    REP(i, H){
        string s;
        cin >> s;
        REP(j, W){
            check[i][j] = false;
            int tate = min(i, H-1-i);
            int yoko = min(j, W-1-j);
            D[i][j] = min(tate, yoko);
            if(s[j]=='#'){
                A[i][j] = 0;
            }else if(s[j]=='.'){
                A[i][j] = 1;
            }else{
                A[i][j] = 2;
                si = i;
                sj = j;
            }
        }
    }
    int res = INT_MAX/3;
    queue<bfs> que;
    bfs s(si, sj, 0);
    que.push(s);
    while(!que.empty()){
        //cout << que.size() << endl;
        bfs b = que.front();que.pop();
        //cout << b.x << " " << b.y << " " << b.dist << endl;
        res = min(res, D[b.x][b.y]);
        if(b.dist < K){
            if(check[b.x+1][b.y] == false && A[b.x+1][b.y] != 0 && b.x+1<W){
                bfs b1(b.x+1, b.y, b.dist+1);
                check[b.x+1][b.y] = true;
                que.push(b1);
            }
            if(check[b.x-1][b.y] == false && A[b.x-1][b.y] != 0 && b.x-1>-1){
                bfs b1(b.x-1, b.y, b.dist+1);
                check[b.x-1][b.y] = true;
                que.push(b1);
            }
            if(check[b.x][b.y+1] == false && A[b.x][b.y+1] != 0 && b.y+1<H){
                bfs b1(b.x, b.y+1, b.dist+1);
                check[b.x][b.y+1] = true;
                que.push(b1);
            }
            if(check[b.x][b.y-1] == false && A[b.x][b.y-1] != 0 && b.y-1>-1){
                bfs b1(b.x, b.y-1, b.dist+1);
                check[b.x][b.y-1] = true;
                que.push(b1);
            }
        }
    }
    cout << (res==0 ? 1 : 2 + (res-1)/K) << endl;
    return 0;
}

Measured memory_bytes: 8192
from sys import exit
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
if N == 25:
    print("Christmas")
elif N == 24:
    print("Christmas Eve")
elif N == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


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

    cout << max(A+A-1,max(A+B, B+B-1)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>


const int STMAX = 3001;

int DP[STMAX][STMAX];
char lcs[STMAX];

int main() {

	std::string s, t;
	std::cin >> s >> t;

	//build DP[][]
	for (int i = 1; i <= s.size(); ++i) {
		for (int j = 1; j <= t.size(); ++j) {
			if (t[j - 1] == s[i - 1]) {
				DP[i][j] = DP[i - 1][j - 1] + 1;
			}
			else {
				DP[i][j] = std::max(DP[i - 1][j], DP[i][j - 1]);
			}
		}
	}
	/*
	for (int i = 1; i <= s.size(); ++i) {
		for (int j = 1; j <= t.size(); ++j) {
			std::cout << DP[i][j] << ' ';
		}
		std::cout << '\n';
	}
	*/

	//get the sequence
	int i = s.size();
	int j = t.size();

	while (DP[i][j] != 0) {

		if ((i == 0 && j == 0)) {
			lcs[0] = s[0];
			break;
		}

		if (DP[i - 1][j] == DP[i][j]) {
			--i;
			continue;
		}

		if (DP[i][j - 1] == DP[i][j]) {
			--j;
			continue;
		}

		lcs[DP[i][j] - 1] = s[i - 1];
		--i;
		--j;
	}

	lcs[DP[s.size()][t.size()]] = '\0';

	std::cout << lcs;

	return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	if (n == 1 && m == 0) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> s(m), c(m);
	for (int i = 0; i < m; i++)
		cin >> s[i] >> c[i];
	int ans[3];
	ans[0] = -1;
	ans[1] = -1;
	ans[2] = -1;
	for (int i = 0; i < m; i++)
		ans[s[i] - 1] = c[i];
	for (int i = 0; i < m; i++) {
		if (ans[s[i] - 1] != c[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	if (n != 1 && ans[0] == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (ans[0] == -1)
		ans[0] = 1;
	for (int i = 0; i < n; i++)
		if (ans[i] == -1)
			ans[i] = 0;
	for (int i = 0; i < n; i++)
		cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = tuple(map(int, input().split()))
grid = [list(input()) for _ in range(h)]

rm_h = [i for i, line in enumerate(grid) if all([x == '.' for x in line])]

rm_w = [i for i in range(w) if all([grid[j][i] == '.' for j in range(h)])]

arc_grid = [[grid[j][i] for i in range(w) if not i in rm_w] for j in range(h) if not j in rm_h]
for i in range(h-len(rm_h)):
  for j in range(w-len(rm_w)):
    print(arc_grid[i][j], end='')
  print('')

Measured memory_bytes: 4596
n = int(input())
a = [int(x) for x in input().split()]
d = {}

for i in range(n):
    tmp = a[i]
    if tmp not in d:
        d[tmp] = 0
    d[tmp] += 1

flag1 = False
flag2 = False

for kk in sorted(d.keys(),reverse = True):
    if d[kk] >= 2 and flag1 == False:
        mx_v = kk
        flag1 = True
        d[kk] -= 2
    if flag1 == True and flag2 == False and d[kk] >= 2:
        mn_v = kk
        flag2 = True

if flag1 and flag2:
    print(mx_v * mn_v)
else:
    print(0)


Measured memory_bytes: 17960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,i,j;
    cin>>n;
    string s;
    map<string ,int>mmp;
    mmp["AC"]=mmp["TLE"]=mmp["RE"]=mmp["WA"]=0;
    for(i=0; i<n; i++)
    {
        cin>>s;
        mmp[s]+=1;
    }
    cout<<"AC x "<<mmp["AC"]<<endl;

cout<<"WA x "<<mmp["WA"]<<endl;

cout<<"TLE x "<<mmp["TLE"]<<endl;

cout<<"RE x "<<mmp["RE"]<<endl;

    return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		
		long tot = 0;
		for(int i=0;i<N;i++){
			if(A[i] != 0){
				tot += A[i];
			} else {
				ans += tot / 2;
				tot = 0;
			}
		}
		
		ans += tot / 2;
		
		Console.WriteLine(ans);
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = new long[N];
		for(int i=0;i<N;i++) A[i] = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17336
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1e9+7;
int n, k;
vector< vector<int> > edg;
int f(int v, int p){
    int res = 1;
    int t = k-2;
    if(p == -1){
        res = k;
        t++;
    }
    for(int i=0;i<edg[v].size();i++){
        if(edg[v][i] != p){
            res = ((long long)res * t-- % mod) * f(edg[v][i], v) % mod;
        }
    }
    return res;
}
int main(void){
    cin >> n >> k;
    edg.assign(n, vector<int>());
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edg[a].push_back(b);
        edg[b].push_back(a);
    }
    cout << f(0, -1) << endl;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,c,i,ans;
cin>>c>>n;
int a[n];
ans=c;
for(i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for(i=0;i<=n;i++)
{
if(!binary_search(a,a+n,c-i)&&(c-i)>=0)
{
cout<<c-i<<endl;
break;
}
else if(!binary_search(a,a+n,c+i))
{
cout<<c+i<<endl;
break;
}
}

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
ll n,T,a,t[200000]={};

int main(){
	cin >> n >> T;
	REP(i,0,n) cin >> t[i];
	int s=t[n-1]+T,c=0;
	REP(i,0,n) c+=(t[i+1]-(t[i]+T)>=0?t[i+1]-(t[i]+T):0);
	cout << s-c << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}

ll ans=1;
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	rep(i,n){
		ans*=10ll;
		ans%=mod;
	}
	ll now=1ll;
	rep(i,n){
		now*=9ll;
		now%=mod;
	}
	ans-=now;
	ans+=mod;
	ans-=now;
	ans+=mod;
	ans%=mod;
	now=1ll;
	rep(i,n){
		now*=8ll;
		now%=mod; 
	} 
	ans+=now;
	ans%=mod;
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3644