akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N, M; cin >> N >> M;
	vector<string> A(N);
	vector<string> B(M);
	REP(i,N) cin >> A[i];
	REP(i,M) cin >> B[i];

	REP(i,N-M+1){
		REP(j,N-M+1){

			bool ans = true;
			REP(k,M){
				if(A[k+i].substr(j,M) != B[k]) ans = false;
			}

			if(ans == true){
				cout << "Yes" << endl;
				return 0;
			}


		}
	}

	cout << "No" << endl;
	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        int count = 0;
        while (count < k) {
            count++;
            if (a % 2 == 1) a--;
            b += a / 2;
            a = a / 2;
            
            if (count >= k) break;
            
            count++;
            if (b % 2 == 1) b--;
            a += b / 2;
            b = b / 2;
        }
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int t;
    cin>>t;
    map<string,int> m;
    while(t--)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3628
import numpy as np
import sys
import math

# n = map(int,input().split())

ans = 0
n = int(input())

for x in range(n+1):
    if x % 3 == 0 and x % 5 == 0:
        continue

    if x % 3 == 0:
        continue

    if x % 5 == 0:
        continue

    ans += x

print(ans)

Measured memory_bytes: 27112
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

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

#define dump(o) cerr << #o; for (auto e : (o)) cerr << " " << e; cerr << endl;
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

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

//??§?¨???§???
//v: ??§???????????§?¨??????? ????????????
template<typename T>
void compress(vector<T> &v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

//??§?¨???§???(map)
//v: ??§???????????§?¨??????? ????????????
//?????????: zip[??§???????????§?¨?]:??§???????????§?¨? (zip.size()<=10^5?????????????????????)
template<typename T>
map<T, T> compressMap(vector<T> &v) {
	map<T, T> zip;
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (T i = 0; i < v.size(); i++) zip[v[i]] = i;
	return zip;
}

//??§???????????§?¨?
//index(??§???????????§?¨?, ??§???????????§?¨??????????(??????) )
template<typename T>
int index(T i, vector<T> v) { return lower_bound(v.begin(), v.end(), i) - v.begin(); }

#define MAX 5100

//Sample2
//https://gyazo.com/39c67d1abe7a6a686acb52285f8a0bc9

int main() {
	//2?¬?????´???????
	static int cumsum[MAX][MAX] = {};
	int xs[MAX], ys[MAX];
	int n, m; cin >> n >> m;
	vector<int> x(n + 1), y(n + 1);
	for (int i = 0; i < n; i++) {
		cin >> xs[i] >> ys[i];
		x[i] = xs[i]; y[i] = ys[i];
	}
	compress(x);
	compress(y);

	//map<int, int> zipx(compressMap(x));
	//map<int, int> zipy(compressMap(y));
	//dump(x);
	//dump(zipx);
	//dump(y);
	//dump(zipy);

	for (int i = 0; i < n; i++) {
		int vx = index(xs[i], x);
		int vy = index(ys[i], y);
		cumsum[vx + 1][vy + 1]++;
	}
	for (int vy = 0; vy < y.size(); vy++)
		for (int vx = 0; vx < x.size(); vx++)
			cumsum[vx + 1][vy + 1] += cumsum[vx + 1][vy] + cumsum[vx][vy + 1] - cumsum[vx][vy];

	for (int i = 0; i < m; i++) {
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		x1 = index(x1, x);
		x2 = index(x2 + 1, x);
		y1 = index(y1, y);
		y2 = index(y2 + 1, y);
		cout << cumsum[x2][y2] - cumsum[x2][y1] - cumsum[x1][y2] + cumsum[x1][y1] << endl;
	}
	return 0;
}

Measured memory_bytes: 102864
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  string s;
  cin >> n >> s >> k;
  char c = s.at(k - 1);
  for(int i = 0;i < n;i++) {
    if(s.at(i) != c) {
      s.at(i) = '*';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
  int N;
  scanf("%d",&N);
  int n1 = N%10;
  if(n1 == 3){
    printf("bon");
  }else if(n1 == 0 ||n1 == 1){
     printf("pon");
  }else if(n1 == 6||n1 == 8){
     printf("pon");
  }else{
     printf("hon");
  }
  
  return 0;
}

Measured memory_bytes: 1692
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c=0;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	if (T[u].p == NIL) {
		cout << "root, ";
	}
	else if (T[u].l == NIL) {
		cout << "leaf, ";
	}
	else {
		cout << "internal node, ";
	}

	cout << "[";
	for (i = 0, c = T[u].l; c != NIL;i++, c = T[c].r) {
		if (i) {
			cout << ", ";
		}
			cout << c;
		
	}
	cout << "]" << endl;
}

//再帰的に深さを求める関数
void setDepth(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) {
		setDepth(T[u].r, p);
	}
	if (T[u].l != NIL) {
		setDepth(T[u].l, p + 1);

	}
}

int main() {
	int i, j, d, v, c=0, l, r;
	cin >> n;
	for (i = 0;i < n;i++) {
		T[i].p = T[i].l = T[i].r = NIL;
	}
	for (i = 0;i < n; i++) {
		cin >> v >> d;
		
		for (j = 0;j < d; j++) {
			cin >> c;
			if (j == 0) {
				T[v].l = c;
			}
			else(T[l].r = c);
			l = c;
		    T[c].p = v;
		}
	}
	for (i = 0;i < n;i++) {
		if (T[i].p == NIL)r = i;
	}
	setDepth(r, 0);
	for (i = 0;i < n;i++) {
		print(i);
	}
	return 0;

}



Measured memory_bytes: 7736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;
int main() {
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	for (ll i = K; i <= N + 1; i++) {
		ll mi = ((0+i-1)*i)/2;
		ll ma = (2*N-i+1)*i/2;
		ans += (ma - mi + 1) % MOD;
        ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<5; i++) {
            int num = sc.nextInt();
            if(num==0) {
                System.out.println(i+1);
            }
        }
    }
}


Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int N,M,X;
  cin>>N>>M>>X;
  vector<vector<int>> data(N, vector<int>(M+1));
  int sum=INF;
  rep(i,N){
   rep(j,M+1){
     cin>>data[i][j];
   }
  }
   for (int tmp = 0; tmp < (1 << 12); tmp++) {
     bitset<12> s(tmp);
     vector<int> vec(M+1);
     bool ans=1;
     rep(k,N){
  if(s.test(k)){
        rep(h,M+1){
          vec[h]+=data[k][h];
        }
      }
     }
    for(int af=1;af<M+1;af++){
       if(vec[af]<X){
       ans=0;
        break;
       }
      }
     if(ans){
      if(sum>vec[0]){
       sum=vec[0];
      }
     }
    }
  if(sum==INF){
cout<<-1;
  }
else{
  cout<<sum;
}
}
    

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int a, b, c;
    cin>>a>>b>>c;
    int a_i=a, b_i=b, c_i=c;
    int count=0;
    while (a%2==0&&b%2==0&&c%2==0)
    {
        count++;
        int a_temp=a;
        int b_temp=b;
        int c_temp=c;
        a=b_temp/2+c_temp/2;
        b=a_temp/2+c_temp/2;
        c=a_temp/2+b_temp/2;
        if (a==a_i&&b==b_i&&c==c_i)
        {
            cout<<-1;
            return 0;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3648
//Kaori Miyazono, did I reach you ?
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
                        
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	lli ans = 1;
	int n;
	cin >> n;
	int nums[n];
	for(int i = 0; i < n; i++){
		cin >> nums[i];
		ans *= 3;
	}
	lli prod = 1;
	for(int i = 0; i < n; i++){
		if ( nums[i] % 2 == 0 ) prod *= 2;
	}
	cout << ans - prod;
	return 0;	
}         






Measured memory_bytes: 256
import bisect
s = list(input())
t = list(input())

ds = {}  # ｓに含まれる文字それぞれの数
dsl = {}  # ｓの文字の位置
for i in range(len(s)):
    if s[i] not in ds.keys():
        ds[s[i]] = 0
        dsl[s[i]] = []
    ds[s[i]] += 1
    dsl[s[i]].append(i)

for i in range(len(t)):
    if t[i] not in ds.keys():
        ds[t[i]] = 0

#print(ds, dsl)

ans = 0
now = -1
for i in range(len(t)):
    if ds[t[i]] == 0:  # ｓにｔを構成する文字がない場合
        print("-1")
        exit()
    elif ds[t[i]] == 1:
        if dsl[t[i]][0] > now:  # ｔの次の文字が現在地より右にある場合
            ans += (dsl[t[i]][0] - now)
        else:  # ｔの次の文字が現在地より左にある場合
            ans += dsl[t[i]][0] + (len(s) - now)
        now = dsl[t[i]][0]
    else:
        index = bisect.bisect_right(dsl[t[i]], now)
        if index == len(dsl[t[i]]):
            index = -1
        if dsl[t[i]][index] > now:  # ｔの次の文字が現在地より右にある場合
            ans += (dsl[t[i]][index] - now)
            now = dsl[t[i]][index]
        else:  # ｔの次の文字が現在地より左にある場合
            ans += dsl[t[i]][0] + (len(s) - now)
            now = dsl[t[i]][0]

print(ans)


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    ll n, m; cin >> n >> m;
    vector<long long int> p(n+1, 0);
    p[0] = 1;
    p[1] = 1;
    ll in;
    rep(i, m){
        cin >> in;
        p[in] = -1;
    }

    rep2(i, 2, n+1){
        if(p[i] == -1) continue;
        p[i] = ((p[i-1] == -1) ? 0 : p[i-1]) + ((p[i-2] == -1) ? 0 : p[i-2]);
        p[i] %= 1000000007;
    }

    cout << p[n]%1000000007 << endl;

    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 2147483647;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct RMQ{
  vector<int> data;
  int N;
  int top(){
    return data[0];
  }
  RMQ(int n){
    N = 1;
    while(N < n) N *= 2;
    data = vector<int>(2 * N, INF);
  }
  void update(int k, int x){
    k += N - 1;
    data[k] = x;
    while(k > 0){
      k = (k - 1) / 2;
      data[k] = min(data[2 * k + 1], data[2 * k + 2]);
    }
  }
  int query(int a, int b, int MIN){
    return query(a, b, 0, 0, N, MIN);
  }
  int query(int a, int b, int k, int l, int r, int MIN){
    if(b <= l || r <= a) return INF;
    else if(a <= l && r <= b){
      return data[k];
    }else if(MIN <= data[k]){
      return MIN;
    }else{
      return min(query(a, b, 2 * k + 1, l, (l + r) / 2, MIN), query(a, b, 2 * k + 2, (l + r) / 2, r, MIN));
    }
  }
};

int main(){
  int H, W, Q;
  while(cin>>H>>W>>Q && H){
    if(H < W){
      //HlogW * Q = 10^7log10^3
      vector<RMQ> rmq(H, RMQ(W));
      REP(y, H){
        REP(x, W){
          int t; scanf("%d", &t);
          rmq[y].update(x, t);
        }
      }
      REP(i, Q){
        int y1, x1, y2, x2;
        scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
        int res = INF;
        for(int y = y1; y <= y2; y++){
          res = min(res, rmq[y].query(x1, x2 + 1, res));
        }
        printf("%d\n", res);
      }
    }else{
      //WlogH * Q
      vector<RMQ> rmq(W, RMQ(H));
      REP(y, H){
        REP(x, W){
          int t; scanf("%d", &t);
          rmq[x].update(y, t);
        }
      }
      REP(i, Q){
        int y1, x1, y2, x2;
        scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
        int res = INF;
        for(int x = x1; x <= x2; x++){
          res = min(res, rmq[x].query(y1, y2 + 1, res));
        }
        printf("%d\n", res);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 17492
"use strict"
 
function main(input) {
  let dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  let items = dataList.map((data, index) => {
    const tmp = data.split(" ")
    return { index: index + 1, city: tmp[0], point: parseInt(tmp[1]) }
  });
  items.sort(function(a, b) {
    if (a.city < b.city) return -1
    if (a.city > b.city) return 1
    if (a.point < b.point) return 1
    if (a.point > b.point) return -1
  })
  items.forEach(item => {
    console.log(item.index);
  })
} 
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int k = scanner.nextInt();
		int ans = 0;
		int max = 0;
		
		ans = cal(a, b, c, k);
		System.out.println(ans);
		
		
		scanner.close();

	}
	
	public static int cal(int a, int b, int c, int n) {
		int max = 0;
		if (n == 0) {
			return a + b + c;
		}
		max = Math.max(max, cal(a*2, b, c, n-1));
		max = Math.max(max, cal(a, b*2, c, n - 1));
		max = Math.max(max, cal(a, b, c*2, n - 1));
		return max;
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  
  cin>>a;
  cin>>b;
  cin>>c;
  cin>>d;
  
  if( a+b == c+d ){
    cout<< "Balanced" <<endl;
  }
  if( a+b < c+d ){
    cout<< "Right" <<endl;
  }
  if(a+b > c+d) {
    cout<< "Left"<<endl;
  }
}

Measured memory_bytes: 256
#coding: utf-8
def GCM(m, n):
    while 1:
        if n == 0: return m
        m -= (m/n)*n
        m,n = n,m
    
while 1:
    try:
        a,b = map(int, raw_input().split())
        x = GCM(a,b)
        y = a*b / x
        print "%d %d" % (x, y)
    except EOFError:
        break

Measured memory_bytes: 4224
n = int(input())
l = list(map(int, input().split()))
count = 0
if len(l) <= 2:
    print(0)
else:
    for i in range(len(l)-2):
        for j in range(len(l)-2-i):
            for k in range(len(l)-2-j-i):
                n1 = l[k+2+i+j]
                n2 = l[j+1+i]
                n3 = l[i]
                if (n1+n2 > n3) and (n1 != n2 and n2 != n3 and n1 != n3) and (n1+n3 > n2) and (n2+n3 > n1):
                    count += 1
    print(count)


Measured memory_bytes: 9200
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 3005;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

ll arr[maxn], dp[maxn][maxn];

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

    int n; cin >> n;

    for (int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    for (int left = n; left >= 1; left--){
        for (int right = left; right <= n; right++){
            if (left == right) dp[left][right] = arr[right];

            dp[left][right] = max(arr[left] - dp[left + 1][right], arr[right] - dp[left][right - 1]);
        }
    }

    cout << dp[1][n] << "\n";

    return 0;
}


Measured memory_bytes: 70016
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int n = nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i] = nextInt();
    }

    int cnt = 1;

    boolean ok = false;

    for(int i=0;i<n;i++){

      if(a[i]==1){
        ok = true;
      }

      if(a[i]==cnt){
        cnt++;
      }
    }

    cnt--; //砕かない数

    int ans = n - cnt; //砕く数

    if(ok){
      System.out.println(ans);
    }
    else{
      System.out.println("-1");
    }


  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 50940
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  map<int,int>k;
  for(int i=0;i<N;i++){
    if(s[i]=='R'){k['R']++;}
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    if(i+1>k['R']&&s[i]=='R'){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;


int32_t main(){
	int n , m , k ; cin >> n >> m >> k ; 
	if(n>m) swap(n,m);
	cout << k/m + ( (k%m==0)?0:1 ) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]D - Dice in Line
            var line = ReadLine();
            int N = line[0];
            int K = line[1];
            var P = ReadLine();

            var dices = GetDices();
            double sum = 0;

            for(int i = 0; i < K; i++)
            {
                sum += dices[P[i]];
            }

            double max = sum;

            for(int i = 0; i < N - K; i++)
            {
                sum += dices[P[i + K]] - dices[P[i]];
                max = Math.Max(max, sum);
            }

            Console.WriteLine(max);
        }

        static double[] GetDices()
        {
            var dices = new double[1001];
            double sum = 0;

            for(int i = 1; i <= 1000; i++)
            {
                sum += (double)i;
                dices[i] = sum / i;
            }

            return dices;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 32348
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	cnt := 0
	max := 0
	for i := 0; i < n; i++ {
		var h int
		fmt.Scan(&h)
		if h >= max {
			max = h
			cnt++
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<string> s(n);
  set<string> exist;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    auto it = exist.find(s[i]);
    if (it != exist.end()) {
      cout << "No\n";
      return 0;
    }
    exist.insert(s[i]);
  }
  char last = s[0][s[0].size() - 1];
  for (int i = 1; i < n; ++i) {
    if (last != s[i][0]) {
      cout << "No\n";
      return 0;
    }
    last = s[i][s[i].size()-1];
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  std::vector<ll> a(3);

  rep(i,0,3)std::cin>>a[i];

  std::sort(all(a));

  if((a[0]==a[1])^(a[1]==a[2]))std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,k = list(map(int,input().split()))
d = list(input().split())

flag = True
while flag:
    check_result = False
    for i in d:
        if i in list(str(n)):
            check_result =True
            break
    if check_result:
        n+=1
    else:
        flag=False
print(n)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
typedef vector<ll> vll;
#define rall(s) s.rbegin(),s.rend()
typedef map<ll,ll> mll;
#define fr(n,x) for(ll n=0;n<x;n++)
#define pb push_back
#define EL cout<<'\n'
#define all(s) s.begin(),s.end()

void solve(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	string s,z;
	cin>>s>>z;

	cout<<z+s;
}

int main(){
    ll T=1;
    //cin>>T;
    while(T--)solve();
}


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

const int INF = (1 << 30) - 1;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin >> n >> k;
    v<int> h(n), dp(n+5, INF); rep(i,n) cin >> h[i];

    dp[0] = 0;
    rep(i,n) {
        for (int j = 1; j <= k; j++) {
            if (i+j >= n) continue;
            chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int D,L,m1,m2;
	scanf("%d %d",&D,&L);
	m1=D/L;
	m2=D%L;
	if(D%L==0)printf("%d\n",m1);
	else printf("%d\n",m1+m2);
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> a, b, c;
    for(int i = 0; i < n; i++) {
        int x, y, z; cin >> x >> y >> z;
        a.push_back(x); b.push_back(y); c.push_back(z);
    }

    int dp_a[n], dp_b[n], dp_c[n];
    dp_a[0] = a[0];
    dp_b[0] = b[0];
    dp_c[0] = c[0];
    for(int i = 1; i < n; i++) {
        // he did a on the ith day
        dp_a[i] = a[i] + max(dp_b[i-1], dp_c[i-1]);
        dp_b[i] = b[i] + max(dp_a[i-1], dp_c[i-1]);
        dp_c[i] = c[i] + max(dp_a[i-1], dp_b[i-1]);
    }
    cout << max(dp_a[n-1], max(dp_b[n-1], dp_c[n-1])) << endl;

    return 0;
}


Measured memory_bytes: 5624
H,W,D = map(int,input().split())
grid = [list(map(int,input().split())) for i in range(H)]
Q = int(input())
info = [list(map(int,input().split())) for i in range(Q)]

note = [0]*(H*W+1)
for i in range(H):
    for j in range(W):
        A = grid[i][j]
        note[A] = (i,j)

cost = []
for s in range(D):
    acc = [0]
    tmp = 0
    for A in range(s,H*W+1-D,D):
        if s == 0 and A == 0:
            acc.append(tmp)
            continue
        i,j = note[A]; ni,nj = note[A+D]
        tmp += abs(ni-i) + abs(nj-j)
        acc.append(tmp)
    cost.append(acc)

def cal(n):
    L,R = info[n]
    index = L % D
    L = L // D; R = R // D
    ans = cost[index][R] - cost[index][L]
    return ans

for loop in range(Q):
    print(cal(loop))

Measured memory_bytes: 45180
n = int(input())
x = list(map(int,input().split(' ')))
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
                if x[i]+x[j] > x[k] and abs(x[i]-x[j]) < x[k] and x[i] != x[j] and x[j] != x[k] and x[i] != x[k]: ans += 1
print (ans)


Measured memory_bytes: 9200
#include <stdio.h>

int keta(long A,long B);

int main(){
  int i,ans,x;
  long N,A,B;
  scanf("%ld",&N);
  ans = 11;
  for(A=1;A*A<=N;A++){
      if(N%A == 0){
        B = N/A;
        x = keta(A,B);
           if(ans>x){
             ans = x;    
           }
         }
      } 
  printf("%ld ",ans);
  return 0;
}
    
int keta(long A,long B){
  int ketaA,ketaB;
  ketaA = 1;
  ketaB = 1;
  if(A>B){
  while(A/10 > 0){
    A /=10;
    ketaA++;
  }
    return ketaA;
  }
  else{
  while(B/10 > 0){
    B /=10;
    ketaB++;
  }
    return ketaB;
  } 
}
    

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main(){
    FIN;
    ll a,b; cin >> a >> b;
    ll x; cin >> x;

    if(a%x != 0){
        cout << b/x - a/x << endl;
        return 0;
    }

    cout << b/x - a/x + 1 << endl;

    return 0;
}


Measured memory_bytes: 3616
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, k = input_to_int_map()
    a = {i + 1: int(val) for i, val in enumerate(input().split())}

    place = 1
    visit = {place}
    place_visits = [place]
    for i in range(k):
        place = a[place]
        if place in visit:
            left = place_visits.index(place)
            return place_visits[left + (k - left) % (i + 1 - left)]
        else:
            visit.add(place)
            place_visits.append(place)

    return place


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 50708
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}
 
int main(){
    ll n,m;
    cin >> n >> m;
    bool z[n];
    ll ansl[n];
    fill (z,z+n,false);
    for (ll i=0;i<m;i++){
        ll s,c;
        cin >> s >> c;
        if (z[s-1]){
            if (ansl[s-1]==c)continue;
            cout << -1 << endl;
            return 0;
        }
        ansl[s-1]=c;
        z[s-1]=true;
    }
    if (z[0] and ansl[0]==0){
        if (n!=1){
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans=0,flag=1;
    for (ll i=0;i<n;i++){
        if (z[n-1-i]){
            ans+=ansl[n-1-i]*flag;
        }
        if (i!=0 and i==n-1 and !z[0]){
            ans+=flag;
        }
        flag*=10;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main(){
    int n,i,r=1,t;
    int arr[999];
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",arr+i);
    qsort(arr,n,4,compare);
    t=arr[0];
    for(i=1;i<n;i++){
        if(t!=arr[i]){
            t=arr[i];
            r++;
        }
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    int l = m / 2, r = m - l;
    int ptr = 0;
    for (int i = l ; i > 0 ; i--) {
        int len = i * 2;
        if ((n - n / 2) % 2 != 0)
            len--;
        cout << n / 2 - ptr - len << ' ' << n / 2 - ptr << '\n';
        ptr++;
    }
    ptr = 0;
    for (int i = r ; i > 0 ; i--) {
        int len = i * 2;
        if ((n - n / 2) % 2 == 0)
            len--;
        cout << n - ptr - len << ' ' << n - ptr << '\n';
        ptr++;
    }

}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

int main(){

	double N, K;
	cin >> N >> K;
	double p = 0;
	double sum_p = 0;
	int n;

	for (int i = 1; i <= N; i ++){

		if (i <= K-1){
			p = 1/N;

			// 何回コインを振らなければいけないか
			n = ceil(log2(K/i));
			//cout << n << endl;
			for (int j = 0 ; j < n ; j++){
				p *= 0.5f;
			}

		}else{
			p = 1/N;
		}

		sum_p += p;
	}
	cout << fixed;
	cout << setprecision(12) << sum_p << endl;

	return 0;
}



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

using namespace std;
int main()
{
    string str;
    cin>>str;
    bool ok = true;
    for(int i =0 ; i <str.size() ; i++ ) {
        
        if(i%2 == 1 && str[i] == 'R') ok = false;
        if(i%2 == 0 && str[i] == 'L') ok = false;
    }
    if(ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

k = [0] * M
s = [[0] * N for i in range(M)]
tmp = [0] * (N + 1)
for i in range(M):
    tmp = [int(i) for i in input().split()]
    k[i] = tmp[0]
    s[i] = tmp[1 : k[i] + 1]

p = [0] * M
p = list(map(int, input().split()))

#電球に接続されたスイッチのonの数
s_cnt = [0] * M
ans = 0

for i in range(2 ** N):
    bit_str = format(i, "0"+str(N)+"b")
    s_on = True
    for j in range(len(bit_str)):
        if bit_str[j] == "1":
            for k in range(len(s)):
                if j+1 in s[k]:
                    s_cnt[k] += 1
    for j in range(len(s_cnt)):
        if s_cnt[j] % 2 != p[j]:
            s_on = False
    if s_on:
        ans += 1
    s_cnt = [0] * M

print(ans)

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

typedef pair<long long, long long> data_t;

int main(){
  long long a,b,x;
  cin>>a>>b>>x;
  long long count=0;
  count+=b/x+1;
  if(a!=0)
      count-=(a-1)/x+1;
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#define UTIL_MAX(x, y) ((x) < (y) ? (y) : (x))

#define MAX_LENGTH 1000
size_t longest_common_subsequence(char arr1[], size_t n1, char arr2[], size_t n2)
{
  size_t lcs[MAX_LENGTH + 1][MAX_LENGTH + 1];
  uint32_t i;
  for (i = 0; i <= n1; i++) {
    lcs[i][0] = 0;
  }
  for (i = 0; i <= n2; i++) {
    lcs[0][i] = 0;
  }

  uint32_t n, m;
  for (n = 1; n <= n1; n++) {
    for (m = 1; m <= n2; m++) {
      if (arr1[n - 1] == arr2[m - 1]) {
        lcs[n][m] = lcs[n - 1][m - 1] + 1;
      } else if (lcs[n - 1][m] >= lcs[n][m - 1]) {
        lcs[n][m] = lcs[n - 1][m];
      } else {
        lcs[n][m] = lcs[n][m - 1];
      }
    }
  }
  return lcs[n1][n2];
}

#if !defined(TEST)
#include <stdio.h>
#include <string.h>

#define BUF_SIZE 1024

int32_t main(void)
{
  int32_t num;
  scanf("%d", &num);
  uint32_t i;
  for (i = 0; i < num; i++) {
    char buf1[BUF_SIZE];
    char buf2[BUF_SIZE];

    scanf("%s", buf1);
    scanf("%s", buf2);
    printf("%d\n", longest_common_subsequence(buf1, strlen(buf1), buf2, strlen(buf2)));
  }
  return 0;
}
#endif

Measured memory_bytes: 8428
#include <stdio.h>

int main(){
  char s[7];
  
  scanf("%s",s);
  if(s[0]=='S')
    printf("Cloudy\n");
  else if(s[0]=='C')
    printf("Rainy\n");
  else
    printf("Sunny\n");
  
  return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  ll ans=1;
  while(1){
    if(ans*ans>n)break;
    ans++;
  }
  cout<<(ans-1)*(ans-1)<<endl;
  return 0;
}


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

public class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int x = Integer.parseInt(buffer.readLine());
        if (x == 0)
            System.out.println(1);
        else
            System.out.println(0);
        System.out.println(sb);
    }
}


Measured memory_bytes: 32564
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

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; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

constexpr int MOD = 1e9 + 7; // 1e9 + 7

/*
0 1 1
1 0 1
1 1 1

"上の列から順に、同じ列を選ばないように、
1 を選んでいく組み合わせの数" と考える。
木？でも同じ列を選べない制約がむずかしい。

  B C
A   C
A B C

上から順に一文字ずつ、文字を全部使って文字列を作る、と考えることもできる。


*/
template<typename F>
struct FixPoint : F {
  FixPoint(F&& f) :F(forward<F>(f)) {}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f) {
  return FixPoint<F>{forward<F>(f)};
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<vector<bool>> a(N, vector<bool>(N));

  F0R(i, N) {

    F0R(j, N) {
      int n;
      cin >> n;
      a[i][j] = (bool)n;
    }
  }

  vector<int> dp(1 << N, -1);

  auto dfs = MFP([&](auto dfs, u32 bits, int r, int c)->int {

    // この列の通過flag
    bits |= 1 << c;

    if (dp[bits] >= 0) {/*NOP*/ }
    else if (r >= N - 1) { dp[bits] = 1; }
    else {
      int result = 0;
      F0R(i, N) {
        if (a[r + 1][i]) {

          // 既に通過した列でなければ
          if (!(bits & (1 << i))) {

            result += dfs(bits, r + 1, i);
            if (result >= MOD) result -= MOD;
          }
        }
      }
      dp[bits] = result;
    }

    return dp[bits];
  });

  int result = 0;
  F0R(i, N) {
    if (a[0][i]) {
      result += dfs(0b0, 0, i);
      if (result >= MOD) result -= MOD;
    }
  }

  cout << result;
}
#endif


Measured memory_bytes: 8448
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k=sc.nextInt(),q=sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = k-q;
        }
        for(int i = 0;i<q;i++){
            a[sc.nextInt()-1] ++;
        }
        for(int i =0;i<n;i++){
            if(a[i]>0){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

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

const int N = 8005;

int n, x, y, vv[2 * N], *v, c, d;
char s[N];
vector<int> xv, yv;

int main(){
    v = vv + N;
    scanf("%s%d%d", s, &x, &y);
    n = strlen(s);
    int i = 0;
    for(; i < n; i++, x--) if(s[i] == 'T') break;
    xv.push_back(0);
    yv.push_back(0);
    for(int j; i < n; i = j){
        for(j = i + 1; j < n; j++) if(s[i] != s[j]) break;
        if(s[i] == 'T') d ^= (j - i) % 2;
        else{
            vector<int> nv, &cv = (d ? yv : xv);
            for(int k : cv){
                if(v[k - (j - i)] != i) nv.push_back(k - (j - i));
                if(v[k + (j - i)] != i) nv.push_back(k + (j - i));
                v[k - (j - i)] = v[k + (j - i)] = i;
            }
            cv = nv;
        }
    }
    puts(count(xv.begin(), xv.end(), x) && count(yv.begin(), yv.end(), y) ? "Yes" : "No");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	vl c(n),f(n),s(n);
	//vvl s(n+1,vl(n+1));
	rep(i,0,n-1)cin>>c[i]>>s[i]>>f[i];
	rep(i,0,n){
		ll t=0;
		rep(j,i,n-1){
			if(t<s[j])t=s[j];
			else if(t%f[j]==0);
			else t+=f[j]-(t-s[j])%f[j];
			t+=c[j];
		}
		cout<<t<<endl;
			
	}
	
	return 0;
}

Measured memory_bytes: 3636
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

signed main(){
    string S;
    cin >> S;
    if(S.back() == 's') cout << S << "es" << endl;
    else cout << S << "s" << endl;
}

Measured memory_bytes: 3604