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

int main(){
  int N;
  string S;
  bool flg = false;
  
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> S;
    if(S == "Y"){
      flg = true;
    }
  }
  
  if(flg == true){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  for(int a1 = 0; a1 <= 100; ++a1) {
    for(int a2 = 0; a2 <= 100; ++a2) {
      for(int a3 = 0; a3 <= 100; ++a3) {
        if(c[0][0]-a1 == c[1][0]-a2 && c[1][0]-a2 == c[2][0]-a3 && c[0][1]-a1 == c[1][1]-a2 && c[1][1]-a2 == c[2][1]-a3 && c[0][2]-a1 == c[1][2]-a2 && c[1][2]-a2 == c[2][2]-a3) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}


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

int main() {
	// your code goes here
	int n,i,k;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++)
	{
	cin>>a[i];
	b[i]=a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
	   k=(n-1)/2;
	   if(b[i]<=a[k])
	   k++;
	   cout<<a[k]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3712
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException{
		Scanner scan = new Scanner(System.in);
		String abc = scan.nextLine();
		String xyz = scan.nextLine();
		int i = 0;
		int j = 0;
		for(i = 0; i < abc.length(); i++, j++){
			System.out.print(abc.substring(i,i+1));
			if(j < xyz.length()){
				System.out.print(xyz.substring(j, j+1));
			}
		}
	}
}


Measured memory_bytes: 20820
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String X = scan.next();
		String Y = scan.next();

		Integer xInt = Integer.parseInt(X, 16);
		Integer yInt = Integer.parseInt(Y, 16);

		if (xInt < yInt) {
			System.out.println("<");
		} else if (xInt > yInt) {
			System.out.println(">");
		} else {
			System.out.println("=");
		}

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

int main()
{
    size_t N, K;
    cin >> N >> K;

    vector<size_t> A(N);
    for (size_t &a : A)
    {
        cin >> a;
    }

    size_t l = 0;
    size_t r = 1000000005;
    while (r - l > 1)
    {
        size_t c = (l + r) / 2;
        size_t k = 0;
        for (size_t a : A)
        {
            if (a > c)
            {
                k += (a + (c - 1)) / c - 1;
            }
        }
        if (k <= K)
        {
            r = c;
        }
        else
        {
            l = c;
        }
    }
    cout << r << endl;
}


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

using namespace std;

int main() {
	string s, p;

	cin >> s >> p;

	s += s;
	for (int i = 0; i < s.length() - p.length(); i++) {
		for (int j = 0; j < p.length(); j++) {
			if (s[i + j] != p[j]) break;
			if (j == p.length() - 1) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1188
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
multiset<int>S;
int n;
int a[100005];
bool pos=false,neg=false;
vector<pair<int,int> >ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		S.insert(a[i]);
		if(a[i]>=0)pos=true;
		if(a[i]<=0)neg=true;
	}
	if(pos&&neg){
		vector<int>v(next(S.begin()),prev(S.end()));
		int Pos=*S.rbegin(),Neg=*S.begin();
		for(auto x:v){
			if(x>=0){
				ans.push_back(make_pair(Neg,x));
				Neg-=x;
			}else{
				ans.push_back(make_pair(Pos,x));
				Pos-=x;
			}
		}
		ans.push_back(make_pair(Pos,Neg));
		cout<<Pos-Neg<<endl;
	}else{
		if(pos){
			int tmp=*S.begin();
			S.erase(S.begin());
			while(S.size()>1){
				ans.push_back(make_pair(tmp,*S.begin()));
				tmp-=*S.begin();
				S.erase(S.begin());
			}
			ans.push_back(make_pair(*S.begin(),tmp));
			tmp=*S.begin()-tmp;
			cout<<tmp<<endl;
		}else{
			int tmp=*S.rbegin();
			S.erase(S.find(tmp));
			while(S.size()){
				ans.push_back(make_pair(tmp,*S.begin()));
				tmp-=*S.begin();
				S.erase(S.begin());
			}
			cout<<tmp<<endl;
		}
	}
	for(auto p:ans){
		cout<<p.first<<" "<<p.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 8428
#include<iostream>

class vec{
  double x,y;
public:
  void set(double a,double b){
    x = a;
    y = b;
  }
  double getx(){return x;}
  double gety(){return y;}
};

double gaiseki(vec v1,vec v2){
  return v1.getx()*v2.gety() - v1.gety()*v2.getx();
}

int main(){
  double x1,y1,x2,y2,x3,y3,xp,yp;
  vec v1,v2,v3;
  int flag = 0;

  while(std::cin >>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
    v1.set(x2-x1,y2-y1);
    v2.set(x3-x1,y3-y1);
    v3.set(xp-x1,yp-y1);
    flag = 0;
    if(gaiseki(v3,v1)*gaiseki(v3,v2) < 0){
      v1.set(x1-x2,y1-y2);
      v2.set(x3-x2,y3-y2);
      v3.set(xp-x2,yp-y2);
      if(gaiseki(v3,v1)*gaiseki(v3,v2) < 0){
        v1.set(x1-x3,y1-y3);
        v2.set(x2-x3,y2-y3);
        v3.set(xp-x3,yp-y3);
        if(gaiseki(v3,v1)*gaiseki(v3,v2) < 0){
          flag = 1;
        }
      }
    }
    if(flag){
      std::cout << "YES" << std::endl;
    }else{
      std::cout << "NO" << std::endl;
    }
  }
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int r=0,b=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='1')
      r++;
    else
      b++;
  }
  cout<<min(r,b)*2<<endl;
  return(0);
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    string S; cin >> S;
    int cnt = 0;
    REP(i, S.length()){
        if(S[i] == '1') ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
    x: usize,
    a: usize,
    b: usize
    }
    let ans = (x - a) % b;
    println!("{}", ans);
}


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

typedef long long ll;
using namespace std;


int main(void) {
   ll N,K;
   cin>>N>>K;
   ll v;
   ll V[N];
   rep(i,N) {
      cin>>v;
      V[i] = v;
   }

   ll ans_max = 0;
   rep(i,K) {
      if (K-i > N) continue;
      rep(j,K-i) {
         multiset<ll> vHave;
         ll ans = 0;
         rep(k,K-i-j) vHave.insert(V[k]);
         REP(k,N-j,N) vHave.insert(V[k]);
         auto itr = vHave.begin();
         rep(k,i) {
            if(!vHave.size() || *itr >= 0) continue;
            itr = vHave.erase(itr);
         }
         for (itr = vHave.begin(); itr != vHave.end();itr++) ans += *itr;
         // cout<<K-i-j<<" "<<j<<" "<<i<<" "<<ans<<endl;
         ans_max = max(ans, ans_max);
      }
   }
   cout<<ans_max<<endl;


   return 0;
}

Measured memory_bytes: 256
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

struct UnionFind {
    vector<int> data;
    vector<i64> rootd;//rootd[i] : dist from node[i] to node[root(i)]
    vector<int> memo;
    explicit UnionFind() {}
    void init(int N) {
        data.assign(N, -1);
        rootd.assign(N, 0);
    }
    void unite(int x_, int y_, i64 weight) {
        int x = root(x_), y = root(y_);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
            rootd[y] = weight - rootd[y_] + rootd[x_];
        }
    }
    int root(int x) {
        memo.clear();
        while(data[x] >= 0) {
            memo.emplace_back(x);
            x = data[x];
        }
        int res = x;
        for(int i = memo.size() - 1; i >= 0; --i) {
            int k = memo[i];
            rootd[k] += rootd[data[k]];
            data[k] = res;
        }
        return res;
    }
    i64 dist(int a, int b) { return rootd[b] - rootd[a];}
    bool same(int a, int b) { return root(a) == root(b);}
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    UnionFind uf;
    while(cin >> n >> m && n) {
        uf.init(n);
        char q; int a, b; i64 w;
        for(int _ : in(m)) {
            cin >> q >> a >> b;
            --a; --b;
            if(q == '?') {
                if(uf.same(a, b))
                    cout << uf.dist(a, b) << '\n';
                else
                    cout << "UNKNOWN" << '\n';;
            }
            else {
                cin >> w;
                uf.unite(a, b, w);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


ll odd[MAX], even[MAX], sum[MAX];


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


  cin >> n >> m;
  vll a(n);
  MAP mp;
  rep(i, n) cin >> a[i];
  rep(i, n) mp[a[i]]++;
  even[0] = a[0];
  sum[0] = a[0];
  FOR(i, 1, n) {
    even[i] = even[i - 1];
    if (!(i % 2)) even[i] += a[i];
    odd[i] = odd[i - 1];
    if (i % 2) odd[i] += a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  rep(i, m) {
    ll x;
    ans = 0;
    cin >> x;
    ll le = COUNT(a,x,0)-1, ri = n - 1, mid;
    le = min(le, n - 2);
    while (ri - le > 1) {
      mid = (le + ri) / 2;
      ll F, S, cur = a[mid], dist = abs(a[mid] - x);
      S = COUNT(a, x + dist, x - dist);
      F = n - mid;
      if (F <= S) ri = mid;
      else le = mid;
    }
    ans += sum[n - 1] - sum[max(0LL, ri - 1)];
    ll num = (n - ri) * 2;
    if (num < n) {
      if (n % 2) ans += even[n - num - 1];
      else ans += odd[n - num - 1];
    }
    cout << ans << endl;
  }



  return 0;
}

Measured memory_bytes: 12168
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    N = int(ipt())
    for h in range(1,3501):
        for n in range(1,3501):
            k = 4*n*h-N*n-N*h
            if k <= 0:
                continue
            if n*h*N%k == 0 and 0<n*h*N//k:
                print(h,n,n*h*N//k)
                exit()

    return None

if __name__ == '__main__':
    main()


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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<string> a(n), b(m);
  for (string &i : a)
    cin >> i;
  for (string &i : b)
    cin >> i;
  int fit = m*m;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int cfit = 0;
      for (int dx = 0; dx < m; dx++) {
        for (int dy = 0; dy < m; dy++) {
          int x = i + dx, y = j + dy;
          if (x < n && y < n) {
            if (a[x][y] == b[dx][dy])
              cfit += 1;
          }
        }
      }
      if (cfit == fit)
        ans = 1;
    }
  }
  cout << (ans == 1 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll x2 = 0;
	rep(i, n) {
		if(i%2) x2 -= a[i];
		else x2 += a[i];
	}
	vector<int> ans(n);
	ans[0] = x2 / 2;
	rep(i, n-1) {
		ans[i+1] = a[i] - ans[i];
	}
	rep(i, n) ans[i] *= 2;
	rep(i, n) printf("%d%c", ans[i], i == n-1? '\n':' ');
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  if (s.at(0) == 'A') {
    int c=0;
    for (int i=1; i<s.size(); i++) {
      if (s.at(i) == 'C' && 2 <= i && i < s.size()-1) c++;
      else if (!('a' <= s.at(i) && s.at(i) <= 'z')) ans = false;
    }
    if (c != 1) ans = false;
  } else ans = false;
  if (ans) printf("AC\n");
  else printf("WA\n");
}

Measured memory_bytes: 256
let () =
  let n = read_int () in
  let a = Array.make_matrix n n 0 in
  let rec read i =
    if i < n then begin
      let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
      let rec g j =
        if j < k then (a.(id-1).(Scanf.scanf "%d " (fun i -> i) - 1) <- 1; g (j + 1))
      in g 0;
      read (i + 1)
    end in
  read 0;
  let rec print i j =
    if i = n then ()
    else if j = n then (print_newline (); print (i + 1) 0)
    else begin
      Printf.printf (if j = 0 then "%d" else " %d") a.(i).(j);
      print i (j + 1)
    end in
  print 0 0

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N;
    cin >> N;
    vector<LL> A(N);
    LL q = 1000000000 + 7;
    REP(i, N){
        LL val;
        cin >> A[i];
    }

    LL sum =0;
    REP(i,N){
        sum+=A[i];
    }

    LL ans = 0;
    LL tmp =0;
    REP(i,N){
        tmp += A[i];
        ans += ((A[i]%q)*((sum - tmp)%q))%q;
    }

    ans = ans % q;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 4792
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>

int main()
{
	while (1)
	{
		int n, k;
		std::cin >> n >> k;

		if (n == 0 && k == 0)
			break;

		std::vector<int> vec(n);
		for (int i = 0; i != n; ++i)
			std::cin >> vec[i];

		int s = 0;
		for (int i = 0; i != k; ++i)
			s += vec[i];

		int m = std::numeric_limits<int>::min();
		m = std::max(s, m);
		for (int i = 0; i != n - k; ++i)
		{
			s -= vec[i];
			s += vec[i + k];
			m = std::max(s, m);
		}

		std::cout << m << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  int n = s.size() ;
  vector<int> count(n,0) ;
  
  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      if(s.at(j)=='A' || s.at(j)=='T' || s.at(j)=='G' || s.at(j)=='C'){
        count.at(i)++ ;
      }
      else{
        break ;
      }
    }
  }
  sort(ALL(count)) ;
  
  /*REP(i,n){
    cout << count.at(i)<<endl ;
  }*/
  
  cout << count.at(n-1) <<endl ;

  return 0 ;
}




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

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

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

	int count = 0;
	for (int i = 1; i <= N; i++)
	{
		//cout << "i=" << i << "; a[i]=" << a[i] << "; a[a[i]]=" << a[a[i]] << endl;
		if (i > a[i])
		{
			continue;
		}

		if (i == a[a[i]])
		{
			count++;
		}
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, k, t;

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}

ll f[210000];
void cominit() {
	f[0] = 1;
	REP(i, 200000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll com(ll n, ll r) {
	return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll perm(ll n, ll r) {
	return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}
int main() {
	cominit();
	cin >> n >> k;
	REPO(i, k) {
		t = com(k - 1, i - 1);
		if (n == k and i == 1) {
			cout << 1 << endl;
			continue;
		}
		ll now = 0;
		if (i <= n - k - 1) now += com(n - k - 1, i) * t;
		if (i <= n - k) now += com(n - k - 1, i - 1) * t * 2;
		if (i > 1 and n - k >= i - 1) now += com(n - k - 1, i - 2) * t;
		cout << now % MOD << endl;
	}
}


Measured memory_bytes: 1792
N,M=gets.split.map &:to_i
b=[1]*(N+1)
r=[false]*(N+1)
r[1]=true
M.times do
  x,y=gets.split.map &:to_i
  r[y]=true  if r[x]
  r[x]=false if b[x]==1
  b[y] += 1
  b[x] -= 1
end
p r.count(true)


Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
pair<string,int> s[200001];
string ans[200001],ts[200001];
int main()
{
	int n;
	cin>>n;
	bool k=true;
	for(int i=1;i<=n;i++)
		cin>>ts[i];
	sort(ts,ts+n+1);
	s[1].first=ts[1];
	s[1].second=1;
	int t=n,m=0;
	for(int i=2;i<=n;i++)
	{
		if(ts[i+m]==ts[i-1+m])
		{
			i--;
			n--;
			m++;
			s[i].second++;
		}
		else
		{
			s[i].first=ts[i+m];
			s[i].second=1;
		}
	}
/*  for(int i=1;i<=n;i++)
	{
		cout<<"first s["<<i<<"]:"<<s[i].first<<" second s["<<i<<"]:"<<s[i].second<<endl;
	}*/
	int big=-1;
	for(int i=1;i<=n;i++)
		if(s[i].second>big)
			big=s[i].second; 
	t=0;
	for(int i=1;i<=n;i++)
		if(s[i].second==big)
		{
			t++;
			ans[t]=s[i].first;
		}
	sort(ans,ans+t+1);
	for(int i=1;i<=t;i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  cout << max({A+B, A-B, A*B}) << "\n";
  return 0;
}


Measured memory_bytes: 3632
package main

import(
	"fmt"
)
func abs(a int)int{
	if a>0{return a}
	return -a
}

func main(){
	var n int
	fmt.Scanln(&n)
	w:=make([]int,n)
	sum:=0
	for i:=0;i<n;i++{
		fmt.Scan(&w[i])
		sum+=w[i]
	}
	ans:=10000000000
	psum:=0
	for i:=0;i<n-1;i++{
		psum+=w[i]
		qsum:=sum-psum
		diff:=abs(psum-qsum)
		if diff<ans{
			ans=diff
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int center = sc.nextInt();
		int start = center - num + 1;

		if (num != 1) {
			for (int i = 0; i < num * 2 - 1; i++) {
				System.out.println(start);
				System.out.println("");
				start++;
			}
		} else {
			System.out.println(center);
		}

	}
}

Measured memory_bytes: 23124
n = int(input())
vals = []
for i in range(n):
    vals.append(list(map(int, input().split())))

dp = [[0 for i in range(3)] for j in range(n)]

for i in range(3):
    dp[0][i] = vals[0][i]


for i in range(1, n):
    for j in range(3):
        if j == 0:
            dp[i][0] = vals[i][0] + max(dp[i-1][1], dp[i-1][2])
        elif j == 1:
            dp[i][1] = vals[i][1]+ max(dp[i-1][0], dp[i-1][2])
        else:
            dp[i][2] = vals[i][2] + max(dp[i-1][0], dp[i-1][1])

print(max(dp[-1][0], dp[-1][1], dp[-1][2]))



Measured memory_bytes: 47384
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);



int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p.at(i);
    sort(ALL(p));
    int ans = 0;
    rep(i, k) {
        ans += p.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1LL<<60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> G[n];
  REP(i, n-1){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  queue<int> q;
  q.push(0);
  int d[n], p[n] = { };
  REP(i, n) d[i] = 1000000;
  d[0] = 0;
  while(q.size()){
    int f = q.front();
    q.pop();
    for(int v: G[f]){
      if(d[v] > d[f]+1){
        d[v] = d[f]+1;
        q.push(v);
        p[v] = f;
      }
    }
  }
  int cur = n-1;
  vector<int> sp;
  sp.pb(n-1);
  while(cur != 0){
    sp.pb(p[cur]);
    cur = p[cur];
  }
  int path[sp.size()];
  int i = 0;
  for(int v: sp){
    path[sp.size()-1-i] = v;
    i++;
  }
  int pt[sp.size()] = { };
  bool x[n] = { };
  REP(i, sp.size()){
    queue<int> qq;
    qq.push(path[i]);
    x[path[i]] = true;
    while(qq.size()){
      int f = qq.front();
      x[f] = true;
      qq.pop();
      for(int v: G[f]){
        if(i != 0 && v == path[i-1]) continue;
        else if(i != sp.size()-1 && v == path[i+1]) continue;
        else if(!x[v]) qq.push(v);
      }
      pt[i]++;
    }
  }
  int fen = 0, snu = 0;
  REP(i, (sp.size()+1)/2) fen += pt[i];
  REP(i, sp.size()/2) snu += pt[sp.size()-1-i];
  if(fen > snu) cout << "Fennec" << endl;
  else if(fen <= snu) cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s,t,u;
  cin >> s >> t >> u;
  if(s==t&&t!=u)cout << "Yes";
  else if(s==u&&t!=u)cout << "Yes";
  else if(u==t&&t!=s)cout << "Yes";
  else cout << "No";
}


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

#define FILE_IN freopen("kotlin.in", "r", stdin);
#define FILE_OUT freopen("kotlin.out", "w", stdout);

#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,a,b) for(int i =a;i<=b;i++)
// for(auto it : g[i].nb)

typedef long long ll;

#define pb push_back

#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const long double PI = acos(-1.0l);
const ll MOD = 1e9+7;

//LLONG_MAX
//-DBL_MAX
//__builtin_popcountll(ll x) - __builtin_popcount(int x)

bool debug = 1;
#define printa(a) cout << #a << " = " << (a) << endl
#define prin(a) if(debug) cout << #a << " = " << (a) << endl
#define soprin(a) if(debug) cout << (a)
#define ppal(a)  if(debug) cout << #a << endl
#define prinsep if(debug) cout << "------" << endl
#define cendl if(debug) cout << endl
#define prinpar(p) if(debug) cout << #p << ".fi=" << (p).fi << " " << #p << ".se=" << (p).se << endl
#define print(tup) if(debug) cout << #tup << " = {" << get(tup,0) << ", " << get(tup,1) << ", " << get(tup,2) << "}\n"
#define prinv(v) if(debug){ cout << #v << ":" << endl; for(auto it = (v).begin(); it!=(v).end();it++){ cout << *it << " ";} cout << endl;}

const int N = -1;

vector<int> aux;

vector<vector<int>> mat;

string s;

int n;

void frrec(int id){
	if(id==n){
		mat.pb(aux);
		//aux.pop_back();
	}
	int i = 1;
	while(id+i<=n){
		aux.pb(i);
		frrec(id+i);
		aux.pop_back();
		i++;
	}
	
	return;	
}

int main(){
	//FILE_IN FILE_OUT
	
	cin >> s;
	n = s.size();
	
	frrec(0);
	
	ll ans = 0;
	
	for(auto &v : mat){
		int i = 0;
		for(auto tam : v){
			ll cur = 0;
			fr(cnt,tam){
				cur = cur*10 + (s[i++]-'0');
			}
			ans+=cur;
		}
	}
	
	/*for(auto &v : mat){
		prinv(v);
	}
	*/	
	
	cout << ans << endl;	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define endl '\n'
using namespace std;
int main()
{
	int s;
	cin>>s;
	vector<int> v;
	vector<int>::iterator it;
	vector<int>::iterator itr;
	vector<int>::iterator IT;
	v.push_back(s);
	int ans = 0;
	while(1)
	{
	    ans++;
	    //cout<<s<<endl;
		if(s%2==0)
			s=s/2;
		else 
		    s = (3*s)+1;
		it = find(v.begin(), v.end(),s);
		if(it==v.end())v.push_back(s);
		else if(it!=v.end()){
			//ans = distance(v.begin(),it);
			v.push_back(s);
			break;
		}
	}
	/*itr = find(it,v.end(),s); 
	IT = (v.begin(),itr);
	ans = distance(v.begin(),IT);*/
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
string s;
int X[2];
vector<int> v[2];
int dir = 1;
bool flag = false;
bool dp[2][8001];
bool check(int k){
	int sum = 0;
	for(int i=0;i<v[k].size();i++)sum += v[k][i];
	if(sum<X[k])return false;
	if((sum-X[k])%2==1)return false;
	int sel = (sum-X[k])/2;
	if(sel>sum)return false;
	int n = v[k].size();
	memset(dp,0,sizeof(dp));
	dp[0][0]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<=8000;j++){
			dp[(i+1)%2][j]=false;
			if(dp[i%2][j])dp[(i+1)%2][j]=true;
			if(k==0&&i==0)continue;
			if(j-v[k][i]>=0&&dp[i%2][j-v[k][i]])dp[(i+1)%2][j]=true;
		}
	}
	return dp[n%2][sel];
}
int main(){
	cin >> s;
	cin >> X[0] >> X[1];
	v[0].pb(0);
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			dir*=-1;
			flag = true;
		}else{
			if(dir==1){
				if(flag){
					v[0].pb(1);
					flag = false;
				}else{
					v[0].back()++;
				}
			}else{
				if(flag){
					v[1].pb(1);
					flag = false;
				}else{
					v[1].back()++;
				}
			}
		}
	}
	/*for(int j=0;j<2;j++){
		for(int i=0;i<v[j].size();i++){
			cout << v[j][i] << ' ';	
		}
		cout << endl;
	}*/
	if(check(0)&&check(1))printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;
const ll INF = 1e18L + 5;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    string s,t;
    cin >> s >> t;

    vector<vector<int> > dp(s.size()+1, vector<int> (t.size()+1,0));

    for(int i=0; i<=s.size(); i++){
        for(int j=0; j<=t.size(); j++){
            if(i==0 || j==0){
                dp[i][j]=0;
                continue;
            }
            if(s[i-1]==t[j-1]){
                dp[i][j]=max(dp[i-1][j-1]+1, max(dp[i-1][j], dp[i][j-1]));
            }
            else
                dp[i][j]=max(dp[i-1][j-1], max(dp[i-1][j], dp[i][j-1]));                
        }
    }

    // for(int i=0; i<s.size()+1; i++){
    //     for(int j=0; j<t.size()+1; j++)
    //         cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    vector<char> ans;
    int i=s.size(), j=t.size();
    while( i>0 && j>0){
        // cout << i << " " << j << endl;
        if(s[i-1]==t[j-1]){
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>=dp[i][j-1]){
            i--;
        }
        else
            j--;
    }


    for(int i=ans.size()-1; i>=0; i--)
        cout << ans[i];
    cout << endl;
    // cout << dp[s.size()][t.size()] << endl;


    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  int plus = 0;
  REP(i, n) {
    cin >> a[i];
    if (a[i] >= 0) plus++;
  }
  SORT(a);
  ll ans = 1;
  if (plus == 0 && k % 2 == 1) {
    REVERSE(a);
    REP(i, k) {
      ans *= a[i];
      ans %= MOD;
    }
    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return;
  }
  int l = 0, r = n - 1;
  REP(i, k) {
    ll lx = a[l] * a[l + 1], rx = a[r] * a[r - 1];
    if (i == k - 1 || rx > lx) {
      ans *= a[r];
      ans %= MOD;
      r--;
    } else {
      ans *= a[l];
      ans %= MOD;
      ans *= a[l + 1];
      ans %= MOD;
      l += 2;
      i++;
    }
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4780
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node{
	int x,y;
}a[220000];
int h,w,n;
bool cmp(node x,node y){
	return x.x<y.x;
}
int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+1+n,cmp);
	int x=1,y=1;
	for(int i=1;i<=n;i++){
		if(a[i].x-x>a[i].y-y){
			printf("%d\n",a[i].x-1);
			return 0;
		}
		y=min(a[i].y-1,y+a[i].x-x);
		x=a[i].x;
	} 
	printf("%d",h);
}

Measured memory_bytes: 1792
// AOJ 2892: Shiritori Compression
// 2019.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int N;
char w[100005];
int dp[100005], a[26];

int main()
{
	int i, j, k;

	memset(a, 0x88, sizeof(a));
	N = in();
	for (i = 0; i < N; i++) {
		w[i] = gc() - 'a';
		while (gc() > ' ');
	}
	for (i = 0; i < N; i++) {
		k = (i > 0)? dp[i-1]: dp[0];
		j = w[i];
		if (a[j] < k) a[j] = k;
		if (i > 0) dp[i] = (dp[i-1] >= a[j])? dp[i-1]: a[j];
		for (j = 0; j < 26; j++) a[j]++;
	}
	printf("%d\n", N-dp[N-1]);
	return 0;
}


Measured memory_bytes: 2252
from collections import defaultdict
def main():
	N, M = map(int, input().split())
	A = list(map(int, input().split()))
	sums = [0]*(N+1)
	ans = 0
	mod = defaultdict(int)
	mod[0] = 1
	for i in range(1, N+1):
		sums[i] = (sums[i-1] + A[i-1]) % M
		ans += mod[sums[i]]
		mod[sums[i]] += 1

	print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15012
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var A = a.ToLower();

            if(a == A)
            {
                Console.WriteLine("a");
            }
            else
            {
                Console.WriteLine("A");
            }


        }
    }
}


Measured memory_bytes: 26296
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[101010];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	i64 ans = 1;
	int ca = 0, cb = 0, cc = 0;
	for(int i = 0; i < n; i++){
		int cnt = 0;
		if(a[i] == ca){
			ca++;
			cnt++;
		}
		if(a[i] == cb){
			if(cnt == 0) cb++;
			cnt++;
		}
		if(a[i] == cc){
			if(cnt == 0) cc++;
			cnt++;
		}
		ans *= cnt;
		ans %= INF;
	}
	
	cout << ans % INF << endl;
	
	return 0;
}

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

int H, W;

bool isOK(int i, int j){
    // cout << H << W << endl;
    return (0<=i and i < H and 0<=j and j<W);
}

int main(){
    
    cin >> H >> W;
    
    string S[H];
    for(int i=0;i<H;i++) cin >> S[i];
    
    int cnt;
    
    for(int l=0; l<H; l++){
        for(int k=0; k<W; k++){
            //  cout << S[l][k];
        }
    }
    
    for(int l=0; l<H; l++){
        for(int k=0; k<W; k++){
            cnt = 0;
            if(S[l][k]=='.'){
                // cnt = 0;
                for(int i=-1; i<=1; i++){
                    for(int j=-1; j<=1; j++){
                        // cout << S[l+j][k+i];
                        if((not(i==0 and j==0)) and isOK(l+j,k+i) and S[l+j][k+i]=='#') cnt++;
                    }
                }
                cout << cnt;
            }else{
                cout << "#";
            }
        }
        cout << endl;
    }
    
    // for(string s:S) cout << s << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
using namespace std;
int dp[100005];
int main()
{
    ll n,d;cin>>n>>d;
    ll a,b;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a*a+b*b<=d*d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#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<string>
#include<unordered_map>
#include<set>
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,k
#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 sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/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 i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll r,g,b,n;
 sc(r);sc(g);sc(b);sc(n);
 ll k;
 ll ans=0;
 ll a=cei(n,r),d=cei(n,g),c=cei(n,b);
 rep(i,0,a+1){
  rep(j,0,d+1){
   if(r*i+g*j>n)break;
   if((n-r*i-g*j)%b==0)ans++;
  }
 }
 pr(ans);
  
return 0;}

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

int main(){

  int N; cin >> N;
  vector<int> w(N);
  for(int i=0; i<N; i++)
    cin >> w.at(i);
  
  int S1, S2;
  int count = 1e9;
  
  for(int i=1; i<N; i++){
    S1 = 0; S2 = 0;
    
    for(int j=0; j<i; j++){
      S1 += w.at(j);
    }
    
    for(int j=i; j<N; j++){
      S2 += w.at(j);
    }
    
    count = min(count, abs(S1-S2));
  
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	string a, b;
	cin>>a; cin>>b;
	n=a.size();
	bool no=1, no2=1;
	for(int i=0; i<n; i++){
		if(a[i]=='1') no2=0;
		if(b[i]=='1') no=0;
	}
	if(no && !no2){
		cout<<-1<<endl;
		return 0;
	}else if(no){
		cout<<0<<endl;
		return 0;
	}
	int d1[2001], d2[2001];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(b[(i-j+n)%n]=='1'){
				d1[i]=j;
				break;
			}
		}
		for(int j=0; j<n; j++){
			if(b[(i+j)%n]=='1'){
				d2[i]=j;
				break;
			}
		}
	}
	int ans=1e9;
	for(int i=0; i<n; i++){
		vector<P> v, v2;
		for(int j=0; j<n; j++){
			if(b[j]!=a[(i+j)%n]){
				v.push_back(P(d1[(i+j)%n], d2[(i+j)%n]));
				v2.push_back(P(d2[(i+j)%n], d1[(i+j)%n]));
			}
		}
		int ans1=1e9;
		sort(v.begin(), v.end());
		sort(v2.begin(), v2.end());
		vector<int> mx, mx2;
		mx.push_back(0); mx2.push_back(0);
		for(int j=v.size()-1; j>=0; j--){
			if(j==v.size()-1){
				mx.push_back(v[j].second);
				mx2.push_back(v2[j].second);
			}else{
				mx.push_back(max(mx.back(), v[j].second));
				mx2.push_back(max(mx2.back(), v2[j].second));
			}
		}
		ans1=min(ans1, i+2*mx[v.size()]);
		ans1=min(ans1, n-i+2*mx2[v.size()]);
		for(int j=0; j<v.size(); j++){
			ans1=min(ans1, 2*max(v[j].first, i)+2*mx[v.size()-1-j]-i);
			ans1=min(ans1, 2*max(v2[j].first, n-i)+2*mx2[v.size()-1-j]-(n-i));
		}
		ans1+=v.size();
		ans=min(ans, ans1);
	}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 256