akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter out = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        StringBuilder sb = new StringBuilder(S);
        String reverse_1 = sb.reverse().toString();

        String S_2 = S.substring(0, (S.length()-1)/2);
        StringBuilder sb_2 = new StringBuilder(S_2);
        String reverse_2 = sb_2.reverse().toString();

        String S_3 = S.substring((S.length()+3)/2 - 1, S.length());
        StringBuilder sb_3 = new StringBuilder(S_3);
        String reverse_3 = sb_3.reverse().toString();
        if(S.equals(reverse_1) && S_2.equals(reverse_2) && S_3.equals(reverse_3)) {
            out.println("Yes");
        }else {
            out.println("No");
        }
        out.flush();
        out.close();
        br.close();
    }
}

Measured memory_bytes: 20948
#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 debug = 1;

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i]=i+1;
    map<vector<int>,int> mp;
    do{
        mp[a]=mp.size();
    }while(next_permutation(a.begin(),a.end()));

    int ans =abs(mp[p]-mp[q]);
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int main(){
	while(true){
		int N,M,Q;
		cin>>N>>M>>Q;
		if(N==0) break;
		bool a[36]={},no[1000][36]={};
		rep(i,Q){
			string s,b;
			cin>>s>>b;
			rep(j,N) if(s[j]=='1') a[j]=!a[j];
			rep(j,M) rep(k,N) if(b[j]=='1'^a[k]) no[j][k]=1;
		}
		rep(i,M){
			int x=-1;
			rep(j,N) if(!no[i][j]){
				if(x==-1) x=j;
				else x=-2;
			}
			if(x>=0){
				if(x<10) printf("%c",'0'+x);
				else printf("%c",'A'+x-10);
			}else{
				cout<<'?';
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1244
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  A.at(0) = 0; A.at(N+1) = 0;
  for (int i=1; i<N+1; i++) cin >> A.at(i);
  vector<int> B(N+1);
  ll sum = 0;
  for (int i=0; i<N+1; i++) {
    B.at(i) = A.at(i+1) - A.at(i);
    if (B.at(i) >= 0) sum += B.at(i);
    else sum -= B.at(i);
  }
  for (int i=1; i<N+1; i++) {
    ll ans;
    if (B.at(i-1) >= 0 && B.at(i) >= 0) ans = sum;
    else if (B.at(i-1) >= 0 && B.at(i) < 0) {
      if (B.at(i-1) >= -B.at(i)) ans = sum + 2*B.at(i);
      else ans = sum - 2*B.at(i-1);
    }
    else if (B.at(i-1) < 0 && B.at(i) >= 0) {
      if (-B.at(i-1) >= B.at(i)) ans = sum - 2*B.at(i);
      else ans = sum + 2*B.at(i-1);
    }
    else ans = sum;
    cout << ans << endl;
  }
}

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

string a,b;

int main(){
	cin >> a >> b;
	int ans;
	if(a.length() > b.length())ans = 1;
	else if(a.length() < b.length())ans = -1;
	else{
		if(a > b)ans = 1;
		if(a < b)ans = -1;
		if(a == b)ans = 0;
	}

	if(ans == 1)puts("GREATER");
	if(ans == -1)puts("LESS");
	if(ans == 0)puts("EQUAL");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll p[]={a,1,0},q[]={b,0,1};
		while(*q){
			ll t=*p/ *q;
			rep(i,3) swap(p[i]-=t*q[i],q[i]);
		}
		if(p[0]<0) rep(i,3) p[i]=-p[i];
		x=p[1],y=p[2];
		return p[0];
	}
	ModInt inv() const {
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<998244353>;
int main(){
	int N,D[100001];
	mint ans=1;
	scan(N);
	rep(i,N){
		scan(D[i]);
	}
	if(D[0]==0){
		sort(D,D+N);
		int kosu[100001]={};
		kosu[0]=1;
		rep1(i,N-1){
			if(D[i]==0){
				prin(0);
				return 0;
			}
			ans*=kosu[D[i]-1];
			kosu[D[i]]++;
		}
		prin(ans);
	}
	else{
		prin(0);
	}
	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
char s[N];
int n, k;

int main() {
  scanf("%s%d", s, &k);
  n = strlen(s);
  for (int  i = 0; i < n; i++) {
    if (s[i] == 'a')
      continue;
    if ('z' - s[i] + 1 <= k) {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  k %= 26;
  while (k--) {
    s[n-1]++;
  }
  printf("%s\n", s);
  return 0;
}

Measured memory_bytes: 384
N,M = map(int,input().split())

L_list = []
R_list = []

for i in range(M):
    L,R = map(int,input().split())
    L_list.append(L)
    R_list.append(R)
L_max = max(L_list)
R_min = min(R_list)

#print(range(L_max,R_min+1))
print(len(range(L_max,R_min+1)))

Measured memory_bytes: 11044
// ITP1_9_B:   Shuffle
// 2017.7.28

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

char *gets(char *s);

int main()
{
	char card[2][210], buf[100];
	int id0, id1;
	int i, m, h, len;

	while (1) {
		gets(card[0]); len = strlen(card[0]); card[1][len] = 0;
		if (card[0][0] == '-') break;
		gets(buf);	m = atoi(buf);
		for (i = 0, id0 = 0; i < m; i++) {
			gets(buf); h = atoi(buf);
			if (h > 0 && h < len) {
				id1 = !id0;
				memcpy(card[id1], card[id0] + h, len - h);
				memcpy(card[id1] + len - h, card[id0], h);
				id0 = id1;
			}
		}
		puts(card[id0]);
	}
	return 0;
}

Measured memory_bytes: 524
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<iterator>
#define ll long long
#define mod 1000000007
#define inf 100000000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,w;
	cin>>n>>w;
	vector<pair<int, int> > items;
	int i,j;
	ll totval=0;
	for(i=0; i<n; i++)
	{
		int weight, value;
		cin>>weight>>value;
		items.push_back(make_pair(weight,value));
		totval+=value;
	}
	ll dp[n][totval+1];
	for(i=0; i<n; i++)
	{
		for(j=0; j<=totval; j++)
		{
			dp[i][j]=inf;
		}
	}
	for(i=0; i<n; i++)
	{
		dp[i][0]=0;
	}
	for(j=1; j<=totval; j++)
	{
		if(items[0].second==j)
		{
			dp[0][j]=items[0].first;
		}
	}
	for(i=1; i<n; i++)
	{
		for(j=1; j<=totval; j++)
		{
			if(items[i].second>j)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=min(dp[i-1][j], dp[i-1][j-items[i].second]+items[i].first);	
			}
		}
	}
	for(j=totval; j>=0; j--)
	{
		if(dp[n-1][j]<=w)
		{
			cout<<j<<"\n";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 78336
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int alice = 0;
        int bob = 0;
        for(int j = 0; j < N; j++) {
            if(j % 2 == 0) {
                alice += arr[N - 1 - j];
            } else {
                bob += arr[N - 1 -j];
            }
        }
        System.out.println(alice - bob);
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint X, Y;
  cin >> X >> Y;
  if(abs(X-Y) <= 1) cout << "Brown" << endl;
  else cout << "Alice" << endl;
}

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

using namespace std;

int main()
{
  int L, R, d;
  
  cin >> L >> R >> d;
  int c = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) {
      c++;
    }
  }
  cout << c << endl;
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
/* }}} */

signed main() 
{
    int n=in();
    PQ<int> a;
    rep(i,n)
    {
        int tmp=in();
        a.push(tmp);
    }
    int alice=0,bob=0;
    while(!a.empty())
    {
        alice+=a.top();
        a.pop();
        if(a.empty()) break;
        bob+=a.top();
        a.pop();
    }
    print(alice-bob);
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){

  int MAX = 200000;
  int R[MAX],n;
  int maxv = -2000000000;
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d", &R[i]);
  }
  int minv = R[0];
  for(i=1;i<n;i++){
    if(maxv<R[i]-minv) maxv = R[i]-minv;
    if(minv>R[i]) minv = R[i];
      } 
  printf("%d\n",maxv);
  //  printf("minv;%d\n", minv);                                                
  return 0;
}





Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	string s;
	cin >> s;
	if(s[0]>='a' && s[0]<='z'){
		printf("a\n");
	}else{
		printf("A\n");
	}
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	if(a<=8 && b<=8)
	{
		cout<<"Yay!";
	}
	else
	{
		cout<<":(";
	}	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 1005
#define M 20005
#define ll long long
using namespace std;
int read()
{
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9')ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
const int ninf=-2e9-5;
int n,h[M],S,T,cur[M];
struct edge{
	int to,nx,cap,cost;
}e[N*N*9];int tot=1;
void add(int u,int v,int cap,int cost)
{
	e[++tot].to=v;e[tot].nx=h[u];h[u]=tot;e[tot].cap=cap;e[tot].cost=cost;
	e[++tot].to=u;e[tot].nx=h[v];h[v]=tot;e[tot].cap=0;e[tot].cost=-cost;
}
bool in[M];
ll dis[M];
int q[M*5000];
bool spfa()
{
	for (int i=1;i<T;++i)dis[i]=ninf,cur[i]=h[i];
	dis[T]=0;in[T]=1;q[1]=T;cur[T]=h[T];
	int head=1,tail=1;
	while (head<=tail)
	{
		int x=q[head];in[x]=0;
		for (int i=h[x];i;i=e[i].nx)
		if (e[i^1].cap&&dis[e[i].to]<dis[x]+e[i^1].cost)
		{
			dis[e[i].to]=dis[x]+e[i^1].cost;
			if (!in[e[i].to])
			in[q[++tail]=e[i].to]=1;
		}
		++head;
	}return dis[S]!=ninf;
}
ll ret;
#define min(a,b) (a<b?a:b)
int Fl(int x,int fl)
{
	if (x==T)return fl;
	in[x]=1;
	int out=0;
	#define i cur[x]
	for (;i&&out<fl;i=e[i].nx)
	if (e[i].cap&&dis[e[i].to]+e[i].cost==dis[x]&&!in[e[i].to]&&cur[e[i].to])
	{
		int v=Fl(e[i].to,min(fl-out,e[i].cap));
		if (v)
		{
			e[i].cap-=v;e[i^1].cap+=v;out+=v;
			ret+=(ll)v*e[i].cost;
		}
	}in[x]=0;
	#undef i
	return out;
}
int main()
{
	n=read();S=n*2+5;T=S+1;
	int X,Y,C;
	for (int i=1;i<=n;++i)
	{
		X=read();
		Y=read();
		C=read();
		add(S,i,C,0);
		add(i,n*2+1,C,X+Y);
		add(i,n*2+2,C,X-Y);
		add(i,n*2+3,C,Y-X);
		add(i,n*2+4,C,-X-Y);
	}
	for (int i=1;i<=n;++i)
	{
		X=read();
		Y=read();
		C=read();
		add(i+n,T,C,0);
		add(n*2+4,i+n,C,X+Y);
		add(n*2+3,i+n,C,X-Y);
		add(n*2+2,i+n,C,Y-X);
		add(n*2+1,i+n,C,-X-Y);
	}
	while (spfa())
	while (Fl(S,20));
	printf("%lld\n",ret);
	return 0;
}

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

int main() {
	
    long long n;
    scanf("%lld", &n);
    long long row;
    for(int i = 1; i <= sqrt(n); i++) {
    	if(n % i == 0) {
    		row = i;
    	}
    }
    long long dep = n / row;
    printf("%lld\n", row + dep - 2);
}

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

int main(){
  long long int n,ans;
  cin >> n;
  ans = 1;
  rep(i,n){ans = (ans*(i+1))%((long long int)(pow(10,9)+7));}
  cout << ans << endl;
  //cout << ans%((long long int)(pow(10,9)+7)) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int c=sc.nextInt();
    
 	if(a==5&&b==5&&c==7){
    		System.out.println("YES");
    	}else if(a==5&&b==7&&c==5){
     		System.out.println("YES");
   	 }else if(a==7&&b==5&&c==5){
    		System.out.println("YES");
    }else{
    		System.out.println("NO");
    }
 
    	
    }
}

Measured memory_bytes: 21844
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1;i <= n;i++)if(i%3 and i%5)ans += i;
	cout << ans;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;

struct student {
    int order;
    int id;
}s[N];


bool cmp(student a, student b) {
    return a.order <= b.order;    
}

int main() {
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++) {
        s[i].id = i + 1;
        scanf("%d", &s[i].order);
    }
    
    sort(s, s + n, cmp);
    
    for(int i=0;i<n-1;i++) {
        printf("%d ", s[i].id);
    }
    printf("%d\n", s[n-1].id);
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;




signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, A; cin >> X >> A;
	if (X < A)print(0)else print(10);
}


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

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

	int ans[n];
	int all_sum = 0;
	for (int i = n-1; i >= 0; i --) {
		int j;
		int sum = 0;
		for (j = 2*(i+1); j <= n; j += i+1) {
			if (j > n) break;
			sum += ans[j-1];
		}
		sum += as[i];
		if (sum % 2 == 1) {
			ans[i] = 1;
			all_sum ++;
		} else {
			ans[i] = 0;
		}
	}

	cout << all_sum << endl;
	bool first = true;
	for (int i = 0; i < n; i ++) {
		if (ans[i] == 0) continue;
		if (first) first = false;
		else {
			cout << " ";
		}
		cout << i+1;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>

int main(void){

char num[1001];

int i=0;

int sum=1;

while(sum!=0){

sum=0;

i=0;

scanf("%c",&num[i]);

while(num[i]!='\n'){

i++;

scanf("%c",&num[i]);

}

num[i]='\0';

i=0;

while(num[i]!='\0'){

sum+=num[i]-'0';

i++;

}

if(sum!=0){

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

}

}

return 0;

}

Measured memory_bytes: 536
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

int cmp_int (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

typedef struct node {
  i32 b, c;
} node;

int cmp_node (const void *a, const void *b) {
  i32 d = ((node *)a)->c - ((node *)b)->c;
  return d == 0 ? 0 : d > 0 ? -1 : 1;
}

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  qsort (a, n, sizeof (i32), cmp_int);
  node *p = (node *) calloc (m, sizeof (node));
  for (i32 i = 0; i < m; ++i) {
    i32 b, c;
    scanf ("%" SCNi32 "%" SCNi32, &b, &c);
    p[i] = (node) {b, c};
  }
  qsort (p, m, sizeof (node), cmp_node);
  for (i32 i = 0, j = 0; i < n; ++i) {
    if (a[i] < p[j].c) {
      a[i] = p[j].c;
      p[j].b--;
    }
    while (j < m && p[j].b == 0) ++j;
  }
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    ans += a[i];
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std ;
#define endl '\n' 

int main() 
{
  int n ; cin >> n ; 
  map <string , int> mp ; 
  
  for(int i = 0 ; i < n ; i++){ 
    string s ; cin >> s; 
    mp[s]++ ; 
  }
  
  cout << "AC x " << mp["AC"] << endl ;
  cout << "WA x " << mp["WA"] << endl ;
  cout << "TLE x " << mp["TLE"] << endl ; 
  cout << "RE x " << mp["RE"] << endl ;
  
  return 0 ;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int L[m], R[m];
  for (int i = 0; i < m; i++)
  {
    cin >> L[i] >> R[i];
  }

  int Min = L[0], Max = R[0];
  for (int i = 1; i < m; i++)
  {
    if (L[i] > Min)
    {
      Min = L[i];
    }
    if (Max > R[i])
    {
      Max = R[i];
    }
  }

  if (Max >= Min)
    cout << Max - Min + 1 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	
	string s; cin >> s;
		
	int l = s.size();

	if (l % 2 == 0 and s[0] == s[l - 1]) {
		cout << "First" << endl;
	}else if (l % 2 == 0 and s[0] != s[l -1]) {
		cout << "Second" << endl;
	}else if (l % 2 != 0 and s[0] == s[l -1]) {
		cout << "Second" << endl;
	}else if (l % 2 != 0 and s[0] != s[l -1]) {
		cout << "First" << endl;
	}


	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>


int main(void){
	int i,j;
	int count[27] = {0};
	char c;

	while(scanf("%c",&c) != EOF){
		for(j = 97;j < 123;j++){
			if(c >= 65 && c <= 90){
				c+=32;
			}else if(c < 97 || c > 122){
				continue;
			}
			if(c == j){
				count[j-97]++;
			}
		}
	}
	for(i = 0;i+97 < 123;i++){
		printf("%c : %d\n",i+97,count[i]);
	}
	return 0;
}

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

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

  int out = 0;
  if (A > B){
    out += A;
    A -= 1;
  } else{
    out += B;
    B -= 1;
  }

  if (A > B){
    out += A;
  } else{
    out += B;
  }

  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M, H[SIZE];
  bool bad[SIZE] = {};

  cin >> N >> M;

  for (int i = 0; i < N; i++) cin >> H[i];

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;

    bad[A] |= H[A] <= H[B];
    bad[B] |= H[B] <= H[A];
  }

  int ans = 0;

  for (int i = 0; i < N; i++) ans += !bad[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4204
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
 
const ll mod = 1e9 + 7;
const ll mmod = 998244353;
 
vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};
 
vector<string> g;
vector<vector<bool>> used;
vector<ll> d;
 
int main() {
    
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n;
    cin >> n;

    ll ret = 0;

    for (ll i = 1; i <= n; ++i)
    {
        ll c = n / i;
        ret += ((i + i * c) * c)  / 2ll;
    }

    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a, b;
    string ans = "Yes";
    cin >> a >> b;
    if(a * b % 2 == 0) ans = "No";
    cout << ans << endl;
    return 0;
}

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

int main(){
  string s, t;
  cin >> s >> t;
  int count = 0;

  for(int i = 0;i < s.length(); i++){
    if(s[i] == t[i]){
      count++;
    }
  }

  cout << count;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long int l[2]={2,1},temp,tem;
		l[0]=2;
		l[1]=1;
	int n;
	cin>>n;
	if(n==0)cout<<2<<endl;
	else if (n==1)cout<<1<<endl;
	else {
	for(int i=2;i<=n;i++){
		temp=l[0]+l[1];
		l[0]=l[1];
		l[1]=temp;
	}
	cout<<l[1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a, b, c, tmp;
	scanf("%d %d %d", &a,&b,&c);
	if (a > b){
	tmp = a;
	a = b;
	b = tmp;
	}
	if (b > c){
	tmp = b;
	b = c;
	c = tmp;
	}
	if (a > b){
	tmp = a;
	a = b;
	b = tmp;
	}
	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 596
import bisect
n = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        k = L[i]+L[j]
        x = bisect.bisect_left(L,k)
        ans += x-j-1
print(ans)
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecveci dp(110,veci(10010,0));

int main() {
    int N,W;
    cin >> N >> W;
    veci v(N),w(N);
    REP(i,N) cin >> v[i] >> w[i];
    REP(i,N) REP(j,W+1) {
        if(j < w[i]) dp[i+1][j] = dp[i][j];
        else dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
    /*
    REP(i,N+1) {
        REP(j,W+1) cout << dp[i][j] << " ";
        cout << endl;
    }
    */
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 6932
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

long dis(long a,long b,long c){
    return max(a,max(b,c))-min(a,min(b,c));
}

int main() {
    long A,B,C;
    cin>>A>>B>>C;
    
    if(A<=C && C<=B) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

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

    lint h;
    cin >> h;

    lint cnt = 0;
    lint pre_cnt = 1;
    while(h > 1){
        h /= 2;
        cnt += pre_cnt;
        pre_cnt *= 2;
        // cout << h << ":" << pre_cnt << endl;
    }
    cnt += pre_cnt;

    COUT(cnt);
    // 1099511627775
    // 2147483647

    return 0;
}

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

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

    int A[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> A[i][j];
        }
    }

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(A[i][j] == -1 or A[i][j] == 1) continue;
            ans += C[A[i][j]][1];
        }
    }
    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;

}
int main(){
  int64_t N,A,B,C;
  cin>>N>>A>>B>>C;
  int64_t a=(A*f(100-C,mod-2))%mod;
  int64_t b=(B*f(100-C,mod-2))%mod;
  int64_t a1=f(a,N);int64_t b1=f(b,N);
  int64_t ans=0;int64_t k=1;int64_t comb=1;
  for(int64_t i=0;i<N-1;i++){
  ans=(ans+(((k*comb)%mod)*(N-1-i))%mod)%mod;
  k=(k*b)%mod;comb=(comb*((f(i+1,mod-2)*(N+i))%mod))%mod;
  }ans=(ans*a1)%mod;swap(a,b);int64_t ans1=0;k=1;comb=1;
  for(int64_t i=0;i<N-1;i++){
  ans1=(ans1+(((k*comb)%mod)*(N-1-i))%mod)%mod;
  k=(k*b)%mod;comb=(comb*((f(i+1,mod-2)*(N+i))%mod))%mod;
  }ans1=(ans1*b1)%mod;ans=(ans+ans1)%mod;ans=(2*N-1-ans)%mod;
  ans=(ans*100)%mod;ans=(ans*f(100-C,mod-2))%mod;
  cout<<(ans+mod)%mod<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
// Created by CAD on 2020/4/19.
#include <bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
#define mst(name, value) memset(name,value,sizeof(name))
#define FOPEN freopen("C:\\Users\\14016\\Desktop\\cad.txt","r",stdin)
#define tst1(a) cout<<#a<<":"<<a<<endl
#define tst2(a, b) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl
#define tst3(a, b, c) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl
#define tst4(a, b, c, d) cout<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl
#define lson (p<<1)
#define rson (p<<1|1)
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define ll long long
#define lowbit(i) (i&-i)
using namespace std;

const int maxn=2e5+5;
ll a[maxn];
ll dp[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    dp[1]=a[1],dp[2]=a[2];
    for(int i=3;i<=n-(n&1);++i){
        if(i&1) dp[i]=a[i]+dp[i-2];
        else dp[i]=a[i]+max(dp[i-2],dp[i-3]);
    }
    if(n&1){
        ll bj=a[n],ans=max(dp[n-1],dp[n-2]);
        for(int i=n-2;i>=3;i-=2){
            ans=max(ans,bj+max(dp[i-1],dp[i-2]));
            bj+=a[i];
        }
        cout<<max(ans,bj)<<"\n";
    }
    else cout<<max(dp[n-1],dp[n]);
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if(a > 9 || b > 9) cout << -1 << endl;
    else cout << a*b << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe 
  ( fromJust )

main = do
  _  <- getLine
  as <- map (fst . fromJust . C.readInt) . C.words <$> C.getLine 
  print $ uncurry (-) $ maxMin as

maxMin :: [Int] -> (Int, Int)
maxMin = (,) <$> maximum <*> minimum

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b; cin >> a >> b;
  string s = "", t = "";
  for(int i = 0; i < b; i++) {
    s += to_string(a);
  }
  for(int i = 0; i < a; i++) {
    t += to_string(b);
  }
  //cout << s << "/" << t;
  string x = min(s, t);
  cout << x << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//
	int A, B, X;
	cin >> A >> B >> X;

	if (A <= X && X <= (A + B)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main(){
    vector <pair <int,int> >x;
    vector <int>y;
    int h,w,n=0;cin>>h>>w;
    int a[h][w]={};
    for(int i=0; i<h*w; i++)
        cin>>a[i/w][i%w];
    for(int i=0; i<h-1; i++){
        for(int j=0; j<w; j++){
            if(a[i][j]%2==1){
                a[i][j]--;
                a[i+1][j]++;
                x.push_back(make_pair(i,j));
                n++;
            }
        }
    }
    for(int i=0; i<w-1; i++){
        if(a[h-1][i]%2==1){
            a[h-1][i]--;
            a[h-1][i+1]++;
            y.push_back(i);
            n++;
        }
    }
    cout<<n<<endl;
    for(int i=0; i<x.size(); i++)
        cout<<x[i].first+1<<" "<<x[i].second+1<<" "<<x[i].first+2<<" "<<x[i].second+1<<endl;
    for(int i=0; i<y.size(); i++)
        cout<<h<<" "<<y[i]+1<<" "<<h<<" "<<y[i]+2<<endl;
    return 0;
}

Measured memory_bytes: 4212
#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 n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int ni = 1;
    rep(i,n) {
        if (a[i] == ni) ni++;
    }
    int ans = n - ni + 1;
    if (ni == 1) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int p,q,r;
    cin >>p>>q>>r;
    cout<<p+q+r-max(p,max(q,r))<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def mat_mul_opt(_mat_info):
    rc_info = list(map(int, _mat_info[0]))
    rc_info.extend(list(map(lambda x: int(x[1]), _mat_info[1:])))

    ans = [[0] * (mat_num + 1) for _ in range(mat_num + 1)]

    for l in range(1, mat_num):
        for i in range(1, mat_num - l + 1):
            j = i + l
            ans[i][j] = 1e7
            for k in range(i, j):
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k + 1][j] +
                                rc_info[i - 1] * rc_info[k] * rc_info[j])

    return ans[1][mat_num]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    mat_num = int(_input[0])
    mat_info = tuple(map(lambda x: x.split(), _input[1:]))
    # assert len(mat_info) == mat_num

    print(mat_mul_opt(mat_info))

Measured memory_bytes: 7876
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    static String[] a;
    static String[] b;
    static String temp;
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        a = scanner.nextLine().split(" ");
        b = scanner.nextLine().split(" ");
        char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
         
        boolean flag = false;
        for(int i=0;i<3;i++){
            for(char d:c){
                roll(d);
                if(Arrays.equals(a, b)){
                    flag=true;
                    break;
                }
            }
        }
        if(flag)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
 
    public static void roll(char c) {
        switch (c) {
        case 'E':
            temp = a[0];
            a[0] = a[3];
            a[3] = a[5];
            a[5] = a[2];
            a[2] = temp;
            break;
        case 'N':
            temp = a[0];
            a[0] = a[1];
            a[1] = a[5];
            a[5] = a[4];
            a[4] = temp;
            break;
        case 'W':
            temp = a[0];
            a[0] = a[2];
            a[2] = a[5];
            a[5] = a[3];
            a[3] = temp;
            break;
        default:
            temp = a[0];
            a[0] = a[4];
            a[4] = a[5];
            a[5] = a[1];
            a[1] = temp;
            break;
        }
    }
 
}


Measured memory_bytes: 26300
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;

int N;
int a[MAX];
void input(){
  cin>>N;
  rep1(i,N)cin>>a[i];
}

vi ans;
int bl[MAX];
void solve(){
  for(int i=N; i>=1; i--){
    int tmp=0;
    for(int k=i; k<=N; k+=i){
      tmp+=bl[k];
    }
    tmp=tmp%2;
    if(a[i]!=tmp){
      bl[i]=1;
      ans.pb(i);
    }
  }

  int M=sz(ans);
  cout<<M<<endl;
  rep(i,M)cout<<ans[i]<<" ";
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  string S, T;
  cin >> S >> T;
  ll N = S.size();

  map<char, set<ll>> mp;
  for (ll i = 0; i < N; i++)
  {
    mp[S.at(i)].emplace(i);
    mp[S.at(i)].emplace(i + N);
  }

  ll ans = -1;
  for (ll i = 0; i < T.size(); i++)
  {
    if (mp[T.at(i)].size() == 0)
      FINALANS(-1);
    ll x = *(mp[T.at(i)].upper_bound(ans % N));
    //cerr << ans << " " << x << endl;
    ans = ans / N * N + x;
  }
  ans++;

  cout << ans << endl;
}

Measured memory_bytes: 9856
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := Scan()
	if s[:n/2] == s[n/2:] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#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 VRSORT(v) sort(v.begin(), v.end(),greater<int>());
#define ALL(X) (X).begin(),(X).end()
#define INF 99999999
#define M_PI 3.14159265358979323846
#define MOD 1000000007

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,K;
vector<ll> A;

void input(){
  #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
  #endif

  fast_io();
  cin >> N >> K;
  A = fetch_vec<ll>(N);
}



int solve(){
  input();

  vector<ll> Sum;
  vector<ll> SumMod;
  Sum.assign(N+1,0LL);
  SumMod.assign(N+1,0LL);
  Sum[0] = 0LL;
  for(ll i=0;i<N;i++) Sum[i+1] = Sum[i]+A[i];
  for(ll i=0;i<=N;i++) SumMod[i] = (Sum[i]+K-i)%K;
  map<ll,ll> strage;
  ll count=0;
  // strage[SumMod[0]]++; 
  for(ll j=0;j<=N;j++){
    count += strage[SumMod[j]];
    strage[SumMod[j]]++;
    if(j-K+1>=0) strage[SumMod[j-K+1]]--;
  }
  // 普通にやったら無理。TLE.
  // int count=0;
  // for(int i=0;i<N;i++){
  //   ll r=0LL;
  //   for(int j=0;j<K-1;j++){
  //     if(i+j>=N) continue;
  //     r = (r+A[i+j])%K;
  //     if(r==(j+1)) count++;
  //   }
  // }
  cout << count << endl;
  return 0;
}

int main()
{
  solve();
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll a,b;cin>>a>>b;
	ll GCD=gcd(a,b);
	if(GCD==1){
		cout<<1<<endl;
		return 0;
	}
	ll c=GCD,cnt=0;
	for(int i=2;i<=sqrt(c);++i){
		if(c%i==0){
			cnt++;
			while(c%i==0){
				c/=i;
			}
		}
	}
    if(c>1){
        cnt++;
    } 
	cout<<cnt+1<<endl;
}


Measured memory_bytes: 256