akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n;
	cin >> n;
	string ans = "No";
	for (int x = 1; x < 10; x++)
	{
		for (int y = x; y < 10; y++)
		{
			if (n == x * y)
			{
				ans = "Yes";
			}
		}
	}
	
	cout << ans << "\n";


	return 0;
}

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

static const long long INF=1e18;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

vector<long long> divisor(long long N){ //約数列挙
    vector<long long> res;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0){
            res.push_back(i);
            if(i!=N/i) res.push_back(N/i);
        }
    }
    sort(res.begin(),res.end()); //約数を小さい順に列挙 
    return res;
}

int main(){
    long long n;
    cin >> n;
    vector<long long> div=divisor(n);
    long long ans=INF;
    for(int i=0;i<div.size();i++){
        ans=min(ans,n/div[i]+div[i]-2);
    }
    cout << ans << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a+b>n+1||a*b<n){
		puts("-1");
		return 0;
	}
	while(n){
		long long tmp=min(a,n-b+1);
		for(long long i=n-tmp+1;i<=n;i++)
			printf("%lld ",i);
		n-=tmp;
		b--;
	}
	return 0;
} 

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string s;
	bool a=false;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
			a=true;
		if(a&&s[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0,4) << " " << s.substr(4,8) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b){
    int c=min(a,b), d=max(a,b);
    if(d%c==0)return c;
    return GCD(c, d%c);}

int main(){
    int n;cin>>n;
    vector<int> a(n);for(int i=0;i<n;i++)cin>>a[i];
    int mini=100000000;for(int i=0;i<n;i++)mini=min(mini,abs(a[i]));
    int minus=0;for(int i=0;i<n;i++)if(a[i]<0)minus++;
    long long sum=0;for(int i=0;i<n;i++)sum+=abs(a[i]);
    if(minus%2==1)sum-=mini+mini;

    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vll a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ok = n - p, ng = -1;
    while(ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        bool check = a[mid] + m >= a[n - p];
        if(!check) {
            ng = mid;
            continue;
        }
        ll sum = 0;
        for(ll i = 0; i <= n - p; i++) {
            if(i == mid) continue;
            ll dif = a[mid] + m - a[i];
            if(dif > m) dif = m;
            sum += dif;
        }
        if(sum < m * (v - p)) check = false;
        if(check) ok = mid;
        else ng = mid;
    }
    cout << n - ok << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    int N;
    cin >> N;
    double x[N];
    string u[N];
    double X=0,ans=0;
    for(int i=0;i<N;i++){
        cin >> x[i] >> u[i];
        if(u[i]=="JPY"){
            ans = ans+x[i];
        }else{
            ans = ans + x[i]*380000;
        }
    }
    printf("%.10f\n",ans);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            List<int> ks = new List<int>();
            for (int i = 0; i < 3; i++)
            {
                ks.Add(int.Parse(str[i]));
            }
            ks.Sort((a, b) => b - a);
            int n = int.Parse(str[3]);
            int count = 0;
            int Amax = n / ks[0];
            for (int i = 0; i <= Amax; i++)
            {
                for (int k = 0; k <= n-i*ks[0]; k++)
                { int l = n - i * ks[0] - k * ks[1];
                    if (l>=0&&l%ks[2]==0)
                    {
                        count++; }
                }
            }
            Console.WriteLine(count);
            
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == b) {
				count++;
				if (count >= 3) {
					System.out.println("Yes");
					return;
				}
			} else {
				count = 0;
			}
		}

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

}

Measured memory_bytes: 36040
import sys
input = sys.stdin.readline

import heapq

n, m = map(int, input().split())
ab = []

for i in range(n):
    a, b = map(int, input().split())
    ab.append([a, -b])
ab.sort()

l = []

idx = 0
ans = 0
for i in range(1, m+1):
    while idx < n and ab[idx][0] <= i:
        heapq.heappush(l, ab[idx][1])
        idx += 1
    if len(l) > 0:
        ans -= heapq.heappop(l)

print(ans)


Measured memory_bytes: 20776
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int a[5];
	REP(i,5)cin>>a[i];
	sort(a,a+5,greater<int>());
	REP(i,5){
		cout<<a[i];
		if(i!=4)cout<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL>PL;
const LL INF=1e18;
int N;
inline vector<int>inv(const vector<int>&V)
{
    vector<int>ret;
    ret.resize(N);
    int i;
    for(i=0;i<N;i++)
        ret[V[i]]=i;
    return ret;
}
inline vector<int>operator*(const vector<int>&V1,const vector<int>&V2)
{
    vector<int>ret;
    ret.resize(N);
    int i;
    for(i=0;i<N;i++)
        ret[i]=V1[V2[i]];
    return ret;
}
vector<int>idn;
inline vector<int>Pow(vector<int>V,int K)
{
    vector<int>ret=idn;
    while(K>0)
    {
        if(K&1)
            ret=ret*V;
        V=V*V;
        K>>=1;
    }
    return ret;
}
int K,i,j;
vector<int>A[6],B[7];
vector<int>pinv,qinv,ans,t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>K;
    A[0].resize(N);
    A[1].resize(N);
    idn.resize(N);
    for(i=0;i<N;i++)
        cin>>A[0][i];
    for(i=0;i<N;i++)
        cin>>A[1][i];
    for(i=0;i<N;i++)
        A[0][i]--,A[1][i]--,idn[i]=i;
    pinv=inv(A[0]);
    qinv=inv(A[1]);
    A[2]=A[1]*pinv;
    A[3]=pinv;
    A[4]=qinv;
    A[5]=qinv*A[0];
    B[0]=B[1]=B[2]=idn;
    B[3]=A[1];
    B[4]=B[5]=A[1]*pinv;
    B[6]=B[5]*qinv;
    B[6]=B[6]*A[0];
    t=Pow(B[6],--K/6);
    ans=t=t*B[K%6];
    ans=ans*A[K%6];
    t=inv(t);
    ans=ans*t;
    for(i=0;i<N;i++)
        cout<<ans[i]+1<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 8304
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,x,minn,maxn;
int main(){
	cin>>a>>b>>c;
	 if (a%2==0 || b%2==0|| c%2==0) cout<<0<<endl;//全是偶数即可以红蓝相同 
	 else{
	maxn=a;minn=a;
	if (maxn<b) maxn=b;
	if (maxn<c) maxn=c;
	if (minn>b) minn=b;
	if (minn>c) minn=c;
	x=a+b+c-minn-maxn;
	cout<<minn*x<<endl;  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
 string s,t,u;
  int a,b;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(s==u){a--;}
  else b--;
  cout<<a<<" "<<b<<endl;
  return 0;
}
  

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
int a[3];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  REP(i,3){
    cin>>a[i];
  }
  sort(a, a+3);
  P(a[2]*10+a[1]+a[0]);

  return 0;
}


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N;
        string S;
        cin >> N >> S;
        string T;
        for (auto e : S) {
            auto f = (char) ('A' + ((e - 'A') + 26 + N) % 26);
            T += f;
        }
        cout << T << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
AB = [LI() for _ in range(N)]
T_AB = list(zip(*AB))
ans = max(T_AB[0])
ans += T_AB[1][T_AB[0].index(max(T_AB[0]))]
print(ans)


Measured memory_bytes: 36084
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) cout << "No" << '\n';
  else cout << "Yes" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

bool isP(string s) {
    string t;
    t = s;
    reverse(s.begin(),s.end());
    return t == s;
}

int main() {
    string S;
    cin >> S;
    bool ans = true;
    if(!isP(S)) ans = false;
    if(!isP(S.substr(0,S.size()/2))) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  int count = 0;
  for(int i = 1;i <= stoi(n);i++) {
      if(to_string(i).size()%2==1) {
          count++;
      }
  }
  cout << count << '\n';
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))

h.sort()
minimum = 10**10
for i in range(n-k+1):
    minimum = min(minimum,h[i+k-1]-h[i])

print(minimum)

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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

using namespace std;

typedef pair<int,int> Paint;

bool Pairsecond(const Paint& pf,Paint&ps){//sortCompare
  return pf.second < ps.second;
}

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007


/*
確認ポイント
cout<< (char)数値 //数値にあった文字に置き換えられる
cout<< (double)int型/(2など)//小数になる
length(),size()に括弧をつけ忘れてないか;
sort()が使える型//vector,string...
YesNo大文字小文字間違えてないか
cout << fixed << 小数計算//正しい小数表記になる(基本6桁)(e記法回避にも使える)
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
sqrt(数値型)でrootが取れる
vector.unique()は隣接した同じ要素を削除するので先にソートをする
*/
int main(){
  int a,b;cin>>a>>b;
  int nw = 1;
  int z = 0;
  if(b == 1){
    cout << 0 << endl;
    return 0;
  }
  while(true){
    z++;
    nw += a;
    nw--;
    if(b <= nw){
      cout << z << endl;
      return 0;
    }
  }
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline

import math

def main():
    a, b, h, m = map(int, input().split())

    x = abs(h * 30 +  m * 0.5 - m * 6)

    rad = math.radians(x)

    ans_pow = a * a + b * b - 2 * a * b * math.cos(rad)

    print(math.sqrt(ans_pow))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[10000][10000];
long long u[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=1,f=0;
  string s;
  cin>>a;
  a-=2;
  cout <<a*180<<'\n';
  return (0);
}


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

// #define __STDC_FORMAT_MACROS
using namespace std;
// #include <inttype.h>

vector<long long> L;
vector<long long> P;

long long func(int N, long long X){
    // レベルNバーガーの下からX層を食べた時のパティの枚数を返す関数
    if(N == 0){
        return 1;
    }
    if(X == 1){
        return 0;
    }

    if(X == 1 + L[N - 1]){
        return P[N - 1];
    }else if(X == 2 + L[N - 1]){
        return P[N - 1] + 1;
    }else if(X < 1 + L[N - 1]){
        return func(N - 1, X - 1);
    }else if(X < L[N]){
        return(func(N - 1, X - 2 - L[N - 1]) + P[N - 1] + 1);
    }else if(X == L[N]){
        return P[N];
    }

    return -500000000000000;
}

int main(){
    int N;
    long long X = 0;
    scanf("%d %lld", &N, &X);

    // レベルiバーガーの層数とパティの枚数
    L.push_back(1);
    P.push_back(1);
    for(int i = 1; i <= N; i++){
        L.push_back(2 * L[i - 1] + 3);
        P.push_back(2 * P[i - 1] + 1);
    }

    // for(int i = 0; i <= N; i++){
    //     long long x = L[i];
    //     printf("%lld\n", x);
    // }
    // for(int i = 0; i <= N; i++){
    //     long long y = P[i];
    //     printf("%lld\n", y);
    // }
    printf("%lld\n", func(N, X));
    return 0;
}

Measured memory_bytes: 256
/*

This question is nice application of Matrix Chain Multiplication.
because here we have to partition the range into two parts like we do in MCM
and after that calculate the answer on those parts which will be furthur used 
to find the answer.

created by sanyam singhal
*/

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define triplet pair<int,pair<int,int>>
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;
const int N = 500;

ll dp[N][N];
ll sumij[N][N];

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

ll solve_by_dp(vector<ll> &a, ll i, ll j){
  if(j==i){ // if the size is 1 then we dont need to combine it with anything
    return 0;
  }
  else if(dp[i][j]!=-1)
    return dp[i][j];
  else{
    ll ans = LLONG_MAX;
    for(ll k=i+1; k<=j; k++){
      ll part1 = solve_by_dp(a, i, k-1);  //solving for range (i, k-1)
      ll part2 = solve_by_dp(a, k, j);    //solving for range (k, j)

      //after we have calculated cost for combining the slimes in separate parts
      //then our answer will be sum of cost for those parts and
      //cost which will be incurred when we combine these two slimes which is nothing but sum of elements in this range.
      ll curr_ans = part1 + part2 + sumij[i][k-1] + sumij[k][j];
      // cout<<curr_ans<<endl;
      if(curr_ans < ans){
        ans = curr_ans;
      }
    }
    return dp[i][j] = ans;
  }
}

void solve(){
  ll n; cin>>n;
  vector<ll>a(n);
  loop(i, 0, n) 
    cin>>a[i];

  memset(dp, -1, sizeof(dp));
  // loop(i, 0, n)
  //   cout<<a[i]<<" ";

  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      if(i==j){
        sumij[i][j] = a[j];
        continue;
      }
      sumij[i][j] = a[j] + sumij[i][j-1];
    }
  }

  // for(int i=0; i<n; i++){
  //   for(int j=0; j<n; j++){
  //     cout<<sumij[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }

  cout<<solve_by_dp(a, 0, n-1)<<endl;
  return;
}

int main(){

  fastIO;
  // take_fileIO();
  solve();
  return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
#include <string.h>

int main(void){

  int times,m,n,i,j,c[1001][1001];
  char x[1001], y[1001];

  scanf("%d",&times);

  while(times--){
    scanf("%s",x);
    scanf("%s",y);
    m = strlen(x);
    n = strlen(y);
    for(i=1; i<=m; i++){
      c[i][0] = 0;
    }
    for(j=0; j<=n; j++){
      c[0][j] = 0;
    }
    for(i=1; i<=m; i++){
      for(j=1; j<=n; j++){
	if(x[i-1] == y[j-1]){
	  c[i][j] = c[i-1][j-1] + 1;
	}else{
	  if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
	  else c[i][j] = c[i][j-1];
	}
      }
    }
    printf("%d\n",c[m][n]);
  }/*

 reta-n 0;

*/}

Measured memory_bytes: 4332
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>?//小さい順
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define elif else if

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
bool prime(int a){
  if (a < 2)
    return false;
  else if (a == 2)
      return true;
  else if (a % 2 == 0)
      return false;
  for (int i = 3; i <= sqrt(a) + 1; i += 2){
      if (a % i == 0)
          return false;
  }
  return true;
}
int INF=1000000007;

int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int modinv(int a, int m)
{
    int b = m, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
int lcm(int a, int b)
{
    int c = modinv(gcd(a, b), INF);
    return ((a * c) % INF) * (b % INF) % INF;
}
int kaijou(int a){
  int b=1;
  fo(i,a)
    b*=i+1;
  return b;
}
//12だったら{(2,2),(3,1)}みたいな
V<P<int,int>> factorize(int n){
  V<P<int,int>> res;
  for(int i=2; i*i<=n; i++){
    if(n%i)
      continue;
    res.emplace_back(i,0);
    while(n%i==0){
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1)
    res.emplace_back(n,1);
  return res;
}

int pow_kai(int a, int b){
  int c=1;
  while(b>0){//bit全部捨てるまで
    if(b%2){//一番右のbitが1
      c=c*a;
    }
    a=a*a;
    b>>=1;//全体右に1つシフト
  }
  return c;
}

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

//コード
int n;
V<V<P<int,int>>> a;
bool judge(int bit){
  fo(i,n){
    if(!(bit&(1<<i)))
      continue;
    for(auto p:a[i]){
      int b=p.fi;
      int c=p.se;
      if(c==1&&!(bit&(1<<b)))
        return false;
      if(c==0&&(bit&(1<<b)))
        return false;
    }
  }
  return true;
}
signed main(){
  cin>>n;
  a.resize(n);
  fo(i,n){
    int d; cin>>d;
    a[i].resize(d);
    fo(j,d){
      cin>>a[i][j].fi>>a[i][j].se;
      --a[i][j].fi;
    }
  }
  int ans=0;
  for(int bit=0; bit<(1<<n); bit++){
    if(judge(bit)){
      int cnt=0;
      fo(i,n){
        if(bit&(1<<i))
          cnt++;
      }
      ans=max(ans,cnt);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int n;
string s;
int main(){
    cin>>s>>n;
    int m=s.size();	
    for(int i=0;i<m;i++){
    	if('z'-s[i]<n && s[i]!='a')n-=('z'-s[i])+1,s[i]='a';
	if(i==m-1)s[i]+=(n%26);
	if(s[i]-'z'>0)s[i]-=26;
	
    }
    cout<<s<<endl;
    return 0;
}

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

long long A,B,C;
long long AB,BC,AC;
long long red,blue;
long long temp1,temp2,temp3,ans;


int main(){
	cin>>A>>B>>C;
	AB=A*B;
	BC=B*C;
	AC=A*C;
	
	if(C%2==0)temp1=0;
	else temp1=AB;
	if(A%2==0)temp2=0;
	else temp2=BC;
	if(B%2==0)temp3=0;
	else temp3=AC;
	
	ans=temp1<temp2?temp1:temp2;
	ans=ans<temp3?ans:temp3;
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
object Main extends App {
  import scala.math.ceil
  val input = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val (plugPerTap, plugNeedAtLeast) = (input(0), input(1))
  val tapNeeded = ceil((plugNeedAtLeast - 1.0) / (plugPerTap - 1.0)).toInt
  println(tapNeeded)
}

Measured memory_bytes: 27324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;

signed main(){
    ll n;cin>>n;
    vector<ll>a(1LL<<n);
    rep(i,1LL<<n)cin>>a[i];
    vector<ll>ma1(1LL<<n);
    vector<ll>ma2(1LL<<n);
    REP(i,1,1LL<<n){
        for(int j=i;;j=(j-1)&i){
            if(a[j]>=ma1[i]){
                ma2[i]=ma1[i];
                ma1[i]=a[j];
            }else if(a[j]>=ma2[i]){
                ma2[i]=a[j];
            }
            if(j==0)break;
        }
    }
    ll ans=0;
    REP(i,1,1LL<<n){
        ans=max(ans,ma1[i]+ma2[i]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 9420
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int a[] = { 1,2,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51 };

	int k;
	cin >> k;
	cout << a[k-1] << endl;





	

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
string iro ;
  iro = "mu";

  for( int i=0; i<N; i++){
    cin >> iro ;
    if( iro == "Y"){
      cout << "Four" << endl;
      break;}
    if( i == N-1 && iro != "Y"){
      cout << "Three"<< endl; }
   }
}

Measured memory_bytes: 3608
N = int(input())
A = [int(x) for x in input().split()]
Amax, Amin = max(A), min(A)
if Amax - Amin > 1:
  print('No')
elif Amax - Amin == 1:
  solo = A.count(Amin)
  print('Yes' if 0 < Amax - solo <= (N - solo) // 2 else 'No')
else:
  print('Yes' if (Amax == N - 1) or (Amax <= N // 2) else 'No')

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int a[MAX];
vector<int> v;

 main() {
 	int n,T = 0;
    cin >> n;
    if(n == 1){
    	cout <<"YES";
    	return 0;
    }
    REP(i, n) {
    	cin >> a[i];
    	T += a[i];
    }

    if (T % ((n*(n+1))/2) != 0){
        cout << "NO";
        return 0;
    }

    int m = T/((n*(n+1))/2);
    REP(i, n){
    	v.pb(a[(i+1)%n]-a[i]);
    }
    REP(i, v.size()){
    	if(m-v[i] < 0 || (m-v[i])%n) {
    		cout <<"NO";
    		return 0;
    	}
    }
    cout <<"YES";
    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;


int main(){
    int N;

    cin>>N;
    vector<int> vec(N);

    for(auto &&x:vec){
        cin>>x;
    }

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

    cout<<vec.at(N-1)-vec.at(0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#define int long long
using namespace std;
typedef pair<int, int> P;

int mod = 1000000007;
int INF = 1e+15;
int n, m;
int s, t;
int u[200000], v[200000], d[200000];
vector<int> et[100000];
vector<int> ec[100000];
int minS[100000];
int minT[100000];
int cntS[100000];
int cntT[100000];
int cntS2[100000];
int cntT2[100000];

void setMinDist(int minD[], int start) {
	int i;
	priority_queue<P, vector<P>, greater<P> > que;
	
	for (i = 0; i < n; i++) minD[i] = INF;
	que.push(P(0, start));
	minD[start] = 0;
	
	while (!que.empty()) {
		P now = que.top(); que.pop();
		int cst = now.first;
		int pos = now.second;
		for (i = 0; i < et[pos].size(); i++) {
			int npos = et[pos][i];
			if (minD[npos] > minD[pos] + ec[pos][i]) {
				minD[npos] = minD[pos] + ec[pos][i];
				que.push(P(minD[npos], npos));
			}
		}
	}
}

//ここにバグがある！！！
void setWayCnt(int minD[], int cntD[], int start) {
	int i, j;
	priority_queue<P, vector<P>, greater<P> > que;
	static vector<bool> used[100000];
	//static bool pushed[100000];
	
	for (i = 0; i < n; i++) {
		used[i].resize(et[i].size());
		for (j = 0; j < et[i].size(); j++) {
			used[i][j] = false;
		}
		//pushed[i] = false;
	}
	
	for (i = 0; i < n; i++) cntD[i] = 0;
	
	que.push(P(0, start));
	cntD[start] = 1;
	//pushed[start] = true;
	while (!que.empty()) {
		P now = que.top(); que.pop();
		int cst = now.first;
		int pos = now.second;
		for (i = 0; i < et[pos].size(); i++) {
			int npos = et[pos][i];
			if (minD[npos] != minD[pos] + ec[pos][i]) continue;
			if (used[pos][i]) continue;
			used[pos][i] = true;
			//cout << "add <=" << npos + 1<< "<- " << pos +1 << "| " << cntD[pos] << endl;
			cntD[npos] += cntD[pos];
			cntD[npos] %= mod;
			/*if (!pushed[npos])*/ que.push(P(minD[npos], npos));
		}
	}
}

signed main() {
	int i;
	
	cin >> n >> m >> s >> t;
	s--; t--;
	for (i = 0; i < m; i++) {
		cin >> u[i] >> v[i] >> d[i];
		u[i]--; v[i]--;
		et[u[i]].push_back(v[i]);
		et[v[i]].push_back(u[i]);
		ec[u[i]].push_back(d[i]);
		ec[v[i]].push_back(d[i]);
	}
	
	setMinDist(minS, s);
	setMinDist(minT, t);
	setWayCnt(minS, cntS, s);
	//cout << "T" << endl;
	setWayCnt(minT, cntT, t);
	
	int X = minS[t];
	int crash = 0;
	
	for (i = 0; i < n; i++) {
		cntS2[i] = (cntS[i] * cntS[i]) % mod;
		cntT2[i] = (cntT[i] * cntT[i]) % mod;
	}
	
	//頂点
	for (i = 0; i < n; i++) {
		if (minS[i] + minT[i] > X) continue;
		if (minS[i] != minT[i]) continue;
		crash += cntS2[i] * cntT2[i];
		crash %= mod;
	
	}
	
	//cout << crash << endl;
	
	//辺
	for (i = 0; i < m; i++) {
		//cout << minS[u[i]] + minT[u[i]] << endl;
		if (minS[u[i]] > minS[v[i]]) swap(u[i], v[i]);
		if (minS[u[i]] + d[i] + minT[v[i]] > X) continue;
		if (minS[u[i]] >= (X + 1) / 2) continue;
		if (minT[v[i]] >= (X + 1) / 2) continue;
		//cout << "crash(u, v) = " << u[i] << ", " << v[i] << endl;
		crash += cntS2[u[i]] * cntT2[v[i]];
		crash %= mod;
	}
	
	//cout << crash << endl;
	
	//答え
	int ans = cntS[t] * cntT[s];
	ans %= mod;
	ans = (ans + mod - crash) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34268
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
 
 
 
class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
 
    static Scanner cin;
 
    void calc()
    {
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N + 1);
        int[] B = cin.ArrayInt(N);
 
        //Aそれぞれが10^9までなので
        //これのsumはintに収まらないことに注意！
        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            //まずは左を全力で倒す
            int left = Math.Min(A[i], B[i]);
            ans += left;
            A[i] -= left;
            B[i] -= left;
 
            //残った戦力で右を全力で倒す
            int right = Math.Min(A[i + 1], B[i]);
            ans += right;
            A[i + 1] -= right;
            B[i] -= right;
        }
 
        Console.WriteLine(ans);
    }
}
 
 
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 32232
#include <bits/stdc++.h>
#include <iomanip>
#include <unordered_map>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  int d_1;
  int d_10;
  for(int i = 1;i<=d;i++){
    for(int k = 1;k<=m;k++){
      d_1 = i % 10;
      d_10 = i / 10;
      if (d_1==1 || d_10 ==1) {
        continue;
      }else{
        if (k == d_1*d_10){
          ans = ans+1;
        }
      }
      
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Mon Sep  2 10:24:03 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int daycount = 0;
	cin>>n;
	vector<vector<int>>arr(n+1);
	vector<int>tops(n+1);
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < n-1; j++){
			int temp;
			cin>>temp;
			arr[i].push_back(temp);
		}
		tops[i] = 0;
	}
	int gamesCount = 0;
	while(gamesCount < (n*(n-1))/2){
		bool haschosen = 0;
		vector<int>toPlay;
		for(int  i = 1; i <= n; i++){
			if(tops[i]==n-1)continue;
			int expected = arr[i][tops[i]];
			if(arr[expected][tops[expected]] == i && i < expected ){
				gamesCount+=1;
				//cout<<gamesCount<<" : "<<i<<expected<<"\n";
				toPlay.push_back(i);
				toPlay.push_back(expected);
				haschosen = 1;
			}
		}
		if(haschosen){
			//cout<<"here";
			for(auto & a : toPlay){
				tops[a]+=1;
			}
			daycount+=1;
		}
		else{
			cout<<-1<<"\n";
			return 0;
		}
		if(daycount  >=100000){
			cout<<(n*(n-1))/2<<"\n";
			return 0;
		}
		
	}
	cout<<daycount<<"\n";
	return 0;
}


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

main(){
	
	double n ;
	while( cin >> n ){
		if( n < 0 ) break ;
		
		int a = n ;
		double b = n - a ;
		
		vector<int> A ;
		vector<int> B ;
		
		while( a ){
			A.push_back(a%2) ;
			a /= 2 ;
		}
		
		int cnt = 0 ;
		while( b ){
			if( cnt > 4 ) break ;
			int c = b*2 ;
			B.push_back(c) ;
			b = b*2 - c ;
			cnt++ ;
		}
		
		if( A.size() > 8 || B.size() > 4 ){
			cout << "NA" << endl ;
			continue ;
		}else {
			for( int i=A.size()-1 ; i<8 ; i++ ) A.push_back(0) ;
			for( int i=B.size()-1 ; i<4 ; i++ ) B.push_back(0) ;
		}
		int k=128 ;
		for( int i=7 ; i>=0 ; i-- ) cout << A[i] ;
		cout << "." ;
		for( int i=0 ; i<4 ; i++ ) cout << B[i] ;
		cout << endl ;
	}
	
}

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

int r, g, b;

int main() {

    scanf("%d%d%d", &r, &g, &b);

    int rgb = 100*r + 10*g + b;

    if (rgb % 4) {
        // 余りがあるとき => true
        printf("NO\n");
    } else {
        // 余りがないとき0 => False
        printf("YES\n");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next()) + 1;
		long[] l = new long[n];
		l[0] = 2;
		l[1] = 1;
		for(int i=2; i<n; i++){
			l[i] = l[i-2] + l[i-1];
		}
		System.out.println(l[n-1]);
	}
}


Measured memory_bytes: 35524
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    ll cnt = 0, tmp = inf;
    Rep (i, N) {
        ll a, b;
        cin >> a >> b;
        cnt += a;
        if (a > b) {
            chmin(tmp, b);
        }
    }

    ll ans = cnt - tmp;
    if (tmp == inf) ans = 0;

    cout << ans << "\n";
}

Measured memory_bytes: 384
# vim: set fileencoding=utf-8:


def main():
    S = raw_input()
    T = raw_input()
    alp = "abcdefghijklmnopqrstuvwxyz"

    # SとTがmapされていればいい
    for ele in alp:
        t = [j for j, e in enumerate(T) if e == ele]
        if t:
            # "e"がT[t[0]]なら、SではS[t[0]]で参照する
            s = [j for j, e in enumerate(S) if e == S[t[0]]]
            if t != s:
                print("No")
                exit()

    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 13012
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		char[][] p = new char[n][n];
		char[][] q = new char[m][m];
		String s;
		for(int i = 0 ; i < n ; i++){
			s = sc.next();
			for(int j = 0 ; j < n ; j++) p[i][j] = s.charAt(j);
		}
		for(int i = 0 ; i < m ; i++){
			s = sc.next();
			for(int j = 0 ; j < m ; j++) q[i][j] = s.charAt(j);
		}
		sc.close();
		boolean fin = true;
		for(int i = 0 ; i <= n - m && fin ; i++){
			for(int j = 0 ; j <= n - m && fin ; j++){
				boolean eq = true;
				for(int ii = i ; ii < i + m ; ii++){
					for(int jj = j ; jj < j + m ; jj++){
						if(p[ii][jj] != q[ii - i][jj - j]) eq = false;
					}
				}
				if(eq) fin = false;
			}
		}
		if(fin) ou.println("No");
		else ou.println("Yes");
		ou.flush();
	}
}

Measured memory_bytes: 36672
#include <iostream>
using namespace std;
int main ( )
{
	int a,b,s;
	cin>>a>>b>>s;
	if(a>s)
	{
	cout<<"NO";
	return 0;
	}
	else if(a+b<s)
	{
	cout<<"NO";
	return 0; 
	}
	else
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string s, t;
    cin >> s;
    t = s;
    reverse(t.begin(), t.end());
    int ans = 0;
    rep(i, s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int a;
	cin >> a;
	ll ans = 0;
	ll time=1;
	time *= a;
	ans += time;
	time *= a;
	ans += time;
	time *= a;
	ans += time;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n,k;cin >> n >> k;
    vector<double> dp(200001,0.0);
    for (int i = 1; i <= n; i++) {
        dp[i] = 1./n;
    }
    for (int i = 1; i < k; i++) {
        dp[i*2] += dp[i]/2;
    }
    double ans = 0.0;
    for (int i = k; i <= 200000; i++) {
        ans +=dp[i];
    }
    cout <<setprecision(10) << fixed<< ans << endl;
    return 0;
}


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

#define ll              long long int
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll n;
    cin >> n;

    if(n == 0){
        cout<<"0\n";
        return 0;
    }

    vector<vector<ll>> v(n, vector<ll>(3));
    vector<vector<ll>> dp(n, vector<ll>(3));

    for(ll i=0; i<n; i++){
        for(ll j=0; j<3; j++){
            cin >> v[i][j];
            dp[i][j] = 0;
        }
    }
    
    dp[n-1][0] = max(v[n-1][1], v[n-1][2]);
    dp[n-1][1] = max(v[n-1][0], v[n-1][2]);
    dp[n-1][2] = max(v[n-1][0], v[n-1][1]);

    for(ll i=n-2; i>=0; i--){
        dp[i][0] = max(v[i][1] + dp[i+1][1], v[i][2] + dp[i+1][2]);
        dp[i][1] = max(v[i][0] + dp[i+1][0], v[i][2] + dp[i+1][2]);
        dp[i][2] = max(v[i][0] + dp[i+1][0], v[i][1] + dp[i+1][1]);
    }

    ll ans = max(dp[0][0], max(dp[0][1], dp[0][2]));
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n=0;
	int m=0;
	int p=0;
	int ac=0;
	int wa=0;
	string s;
	map<int,int> table;
	cin>>n>>m;
	vector<int>	w(n);
	fill(w.begin(),w.end(),0);
	for(int i=0;i<n;i++)
	{
		table[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		cin>>p>>s;
		if(table[p]==1) continue;
		if(s=="WA")
		{
			w[p]+=1;
		}
		else if(s=="AC")
		{
			table[p]=1;
			ac+=1;
			wa+=w[p];
		}
	}
	cout<<ac<<" "<<wa;
	return 0;
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize "trapv"
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  long double d,t,s; cin >> d >> t >> s;
  
  if(d/s<=t) cout << "Yes\n";
  else cout << "No\n";
  




  return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  dp[6000][6000];

int main(){
  ll N,K,A[10000],sum=0;
  cin >> N  >> K;
  rep(i,N){
    cin >> A[i];
    sum+=A[i];
  }
  if(sum<K){
    cout << N << endl;
    return 0;
  }
  sort(A,A+N,[](const ll &a, const ll &b){return a>b;});
  dp[0][0] = 1;
  ll T = 0;
  ll ma =0;
  Rep(i,1,N+1){
    if(ma + A[i-1]>= K){
        T = i ;
    }
    rep(j,K){
      if(j-A[i-1]>=0){
        if(dp[i-1][j-A[i-1]]==1 || dp[i-1][j] == 1){
          dp[i][j]=1;
          ma = max(j,ma);
        }
      }
      if(dp[i-1][j]==1){
        dp[i][j]=1;
        ma = max(j,ma);
      }
    }
  }
  cout << N-T << endl;
}

Measured memory_bytes: 234112
arr = []
3.times do
  arr << gets.chomp.split(' ').map(&:to_i)
end
n = gets.chomp.to_i
n.times do
  x = gets.chomp.to_i
  3.times do |i|
    3.times do |j|
      arr[i][j] = -1 if arr[i][j] == x
    end
  end
end
ok = false
3.times do |i|
  sum = 0
  3.times do |j|
    sum += arr[i][j]
  end
  ok = true if sum == -3
end
3.times do |i|
  sum = 0
  3.times do |j|
    sum += arr[j][i]
  end
  ok = true if sum == -3
end
ok = true if arr[0][0] + arr[1][1] + arr[2][2] == -3
ok = true if arr[0][2] + arr[1][1] + arr[2][0] == -3
puts ok ? 'Yes': 'No'

Measured memory_bytes: 1788