akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static HashMap<String,String> map = new HashMap<>();

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int count = 0;
		for(int i = 0; i < M; i++) {
			if(a[i] >= N) count++;
		}
		int ans = 0;
		while(count < M-1) {
			int min = 2 << 29;
			int id = -1;
			int c = 0;
			for(int i = 0; i < M; i++) {
				if(a[i] >= N) c++;
				else if(a[i] + b[i] >= N) {
					if(N - a[i] < min) {
						min = N - a[i];
						id = i;
					}
				}
			}
			if(c >= M-1) break;
			ans += N - a[id];
			a[id] = N;
			
			
		}
		System.out.println(ans);
	}
}

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

int N;
double T, A;

int main(){
  cin >> N >> T >> A;
  double dif = 1e8;
  int ans;
  for(int i = 0; i < N; i++){
    double h; cin >> h;
    double n_dif = abs(A - (T - h * 0.006));
    if(n_dif < 0.0) n_dif = -n_dif;
    if(dif > n_dif) {dif = n_dif; ans = i + 1;}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

const ll Inf = 2e18;

ll mul(ll a, ll b) {
  if (a <= Inf / b) return min(Inf, a * b);
  else return Inf;
}

void add(ll &a, ll b) {
  a += b;
  a = min(a, Inf);
}

ll sum(ll a, ll b) {
  return min(Inf, a + b);
}

ll ans, n;
int a, b, c, d;

const int N = 100;

ll dp[N][N][N][2];
ll pr[N][N][N];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> a >> b >> c >> d;
    ans = Inf;
    pr[0][0][0] = 1;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
          if (i + 1 < N) pr[i + 1][j][k] = mul(pr[i][j][k], 2);
          if (j + 1 < N) pr[i][j + 1][k] = mul(pr[i][j][k], 3);
          if (k + 1 < N) pr[i][j][k + 1] = mul(pr[i][j][k], 5);
          dp[i][j][k][0] = dp[i][j][k][1] = Inf;
        }
      }
    }
    auto gettk = [&] (ll x, ll y, int t) {
      if (y == Inf) return Inf;
      ll tk = x / y;

      ll f = x % y;
      ll s = (y - f) % y;
      if ((f < s) ^ t) ++tk;
      return tk;
    };
    auto getx = [&] (ll x, ll y, int t) {
      if (x == Inf || y == Inf) return Inf;
      ll tk = x / y;

      ll f = x % y;
      ll s = (y - f) % y;
      if ((f < s) ^ t) ++tk;

      return abs(x - tk * y);
    };
    dp[0][0][0][0] = dp[0][0][0][1] = 0;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        for (int k = 0; k < N; ++k) {
          for (int t = 0; t < 2; ++t) {
            for (int nt = 0; nt < 2; ++nt) {
              if (i + 1 < N) {
                dp[i + 1][j][k][nt] = min(dp[i + 1][j][k][nt], sum(dp[i][j][k][t], gettk(getx(n, pr[i + 1][j][k], nt), pr[i][j][k], t)));
              }
              if (i + 1 < N) {
                dp[i][j + 1][k][nt] = min(dp[i][j + 1][k][nt], sum(dp[i][j][k][t], gettk(getx(n, pr[i][j + 1][k], nt), pr[i][j][k], t)));
              }
              if (i + 1 < N) {
                dp[i][j][k + 1][nt] = min(dp[i][j][k + 1][nt], sum(dp[i][j][k][t], gettk(getx(n, pr[i][j][k + 1], nt), pr[i][j][k], t)));
              }
            }
            ll tk = gettk(n, pr[i][j][k], t);
            ll need = sum(dp[i][j][k][t], tk);
            ll all = mul(need, d);
            add(all, mul(i, a));
            add(all, mul(j, b));
            add(all, mul(k, c));
            ans = min(ans, all);
          }
        }
      }
    }
    cout << ans << '\n'; 
  }
}




Measured memory_bytes: 27056
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[10001]={0},a[100][2];
int main(){
int n,w,i,j;
cin>>n>>w;
for(i=0;i<n;i++)cin>>a[i][0]>>a[i][1];
for(i=0;i<w;i++){
for(j=0;j<n;j++){
if(w>=i+a[j][1])p[i+a[j][1]]=max(p[i+a[j][1]],p[i]+a[j][0]);
}
}
cout<<p[w]<<endl;
return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N;

		cin >> N;

		ll sum = N * (N - 1) / 2;

		cout << sum << '\n';

		return 0;
	}



Measured memory_bytes: 256
def counter():#島の数をカウントする
    count=0
    #12*12個の値をひとつずつ調べる
    for x in range(len(is_data)):
        for y in range(len(is_data)):
            if is_data[x][y] == '1':#島が発見されたら
                dfs(x,y)
                count+=1
    return count
def dfs(x,y):
    if x<0 or x == len(is_data) or y<0 or y == len(is_data):
        return
    if is_data[x][y] == '1':
        is_data[x][y] = '0'
        dfs(x+1,y)
        dfs(x,y+1)
        dfs(x-1,y)
        dfs(x,y-1)

is_data=[]
while True:
    try:
        s = list(input())#入力
        if not s:#空入力のときループぬける
            print(counter())
            is_data=[]
            s = []
        else:
            #ls = len(s)
            is_data.append(s)
            #for i in range(len(is_data)):
                #is_data[i] = list(map(int,is_data[i]))
                #is_data = np.array(is_data).reshape(ls,ls)
#print(is_data)
    except EOFError:
        print(counter())
        break


Measured memory_bytes: 5576
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n,a,b = readInts()
if n == 1 and not a == b:
    print(0)
elif a == b:
    print(1)
elif a > b:
    print(0)
else:
    wa = a+b
    m = wa + b*(n-2)
    i = wa + a*(n-2)
    print(m-i+1)


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

const int MOD = 1e9+7;
const int MAX_N = 60;
int N;
ll K;
int a[MAX_N][MAX_N];

mat mul(const mat& x, const mat& y)
{
	const int n = x.size(), m = x[0].size();
	mat z = mat(n, vec(m));
	for(int i=0;i<n;++i)for(int j=0;j<m;++j){
		for(int k=0;k<n;++k){
			(z[i][j]+=x[i][k]*y[k][j])%=MOD;
		}
	}
	return z;
}

mat mat_power(mat x, ll y)
{
	const int n = x.size();
	mat res(n, vec(n));
	for(int i=0;i<n;++i) res[i][i]=1;
	while(y){
		if(y&1) res=mul(res, x);
		x=mul(x,x);
		y>>=1;
	}
	return res;
}

void solve()
{
	mat A(N, vec(N));
	for(int i=0;i<N;++i)for(int j=0;j<N;++j){
		A[i][j]=a[i][j];
	}
	mat B = mat_power(A, K);
	ll ans = 0;
	for(int i=0;i<N;++i)for(int j=0;j<N;++j){
		(ans += B[i][j])%=MOD;
	}
	cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i)for(int j=0;j<N;++j) cin >> a[i][j];
	solve();
	return 0;
}

Measured memory_bytes: 384
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=100111;

int n,m,lv[maxn],rv[maxn],T,ans[maxn];
bitset<50111>have[50111],all;
bool use[50111];
void solve1()
{
	for(int i=1;i<=n;i++)
	{
		have[i].set(i);
		all.set(i);
	}
	for(int i=m;i>=1;i--)
	{
		bitset<50111> nv=have[lv[i]]|have[rv[i]];
		have[lv[i]]=have[rv[i]]=nv;
	}
	for(int i=1;i<=n;i++)all&=have[i];
	if(!all.any())puts("-1");
	else
	{
		int piv=all._Find_first();
		use[piv]=1;
		for(int i=m;i>=1;i--)if(use[lv[i]]||use[rv[i]])
		{
			if(!use[lv[i]])ans[i]=1;
			else if(!use[rv[i]])ans[i]=0;
			use[lv[i]]=use[rv[i]]=1;
		}
		for(int i=1;i<=m;i++)if(ans[i]==0)putchar('^');else putchar('v');
		puts("");
	}
}
void solve2()
{
	if(n==2)
	{
		puts("-1");
		return;
	}
	pii a1=mp(1,2),a2=mp(2,3);
	for(int i=m;i>=1;i--)
	{
		if(rv[i]>3)continue;
		if(a1.ss<a1.ff)swap(a1.ss,a1.ff);
		if(a2.ss<a2.ff)swap(a2.ss,a2.ff);
//		printf("i= %d a= %d %d b= %d %d\n",i,a1.ff,a1.ss,a2.ff,a2.ss);
		if(mp(lv[i],rv[i])==a1)swap(a1,a2);
		if(lv[i]!=a1.ff&&lv[i]!=a1.ss)swap(lv[i],rv[i]);
		if(a1.ff!=lv[i])swap(a1.ff,a1.ss);
		a2=mp(rv[i],a1.ss);
		if(lv[i]>rv[i])ans[i]=1;
	}
	for(int i=1;i<=m;i++)if(ans[i]==0)putchar('^');else putchar('v');
	puts("");
}

int main()
{
	get3(n,m,T);
	for(int i=1;i<=m;i++)get2(lv[i],rv[i]);
	if(T==1)solve1();
	else solve2();
	return 0;
}

Measured memory_bytes: 308096
def I(): return int(input())
def LI(): return list(map(int,input().split()))
N = I()
h = LI()+[0]
ans = 0
while 1:
    if max(h)==0:
        break
    ans += 1
    for i in range(N+1):
        h[i] -= 1
        if h[i]>=0 and h[i+1]<=0:
            break
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

char S[1000];
int N;

int get_cnt(int n)
{
	bool flg1[100] = {};
	bool flg2[100] = {};
	for (int i = 0; i < n; i++)
	{
		flg1[S[i] - 'a'] = true;
	}
	for (int i = n; i < N; i++)
	{
		flg2[S[i] - 'a'] = true;
	}
	int cnt = 0;
	for (int i = 0; i < 26; i++)
	{
		if (flg1[i] && flg2[i])
		{
			cnt++;
		}
	}
	return cnt;
}

signed main()
{
	cin >> N;
	string s;
	cin >> s;
	REP(i, N) S[i] = s[i];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans = max(ans, get_cnt(i));
	}
	cout << ans << endl;
}



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

int main() {
  int n;
  cin>>n;
  vector<int> w(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>w[i];
    sum+=w[i];
  }
  int ans=1e9,cnt=0;
  for(int i=0;i<n;i++){
    cnt+=w[i];
    int count=sum-cnt;
    int a=abs(cnt-count);
    ans=min(ans,a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()
dic = {}
for i in range(len(s)):
    c = s[i]
    count = dic.setdefault(c, 0) + 1
    dic[c] = count

result = "Yes"
for k in dic:
    if dic[k] != 2:
        result = "No"

print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    ll n, z, w;
    cin >> n >> z >> w;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(n == 1){
        cout << abs(a[0]-w) << endl;
    }else{
        cout << max(abs(a[n-1]-w), abs(a[n-2]-a[n-1])) << endl;
    }
}

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

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

struct att {
	int num;
	int sum;
};

bool cmp(const att &a, const att &b) {
  return a.sum < b.sum;
}

int main() {
  int n;
  cin >> n;
  att a[n];
  for ( int i = 0; i < n ; i++ ) {
    cin >> a[i].sum;
    a[i].num = i+1;
  }
  sort(a, a+n, cmp);

  for ( int i = 0; i < n-1; i++ ) {
    cout << a[i].num << ' ';
  }
  cout << a[n-1].num << endl;
  return 0;
}


Measured memory_bytes: 1536
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int A[200000];
int B[200000];
int N;

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	ARY_SORT(A, N);

	int a = A[N / 2 - 1];
	int b = A[N / 2];

	for (int i = 0; i < N; i++)
	{
		cout << ((B[i] < b) ? b : a) << endl;
	}
}







Measured memory_bytes: 5376
#include <cstdio>
#pragma warning(disable : 4996)
int N, Q, x, y, z, inv2_vert[5009][5009], inv2_diag[5009][5009], imos[5009][5009];
int main() {
	scanf("%d%d", &N, &Q);
	while (Q--) {
		scanf("%d%d%d", &x, &y, &z), x--, y--, z++;
		inv2_vert[x][y]++; inv2_vert[x + z][y]--;
		inv2_diag[x][y + 1]--; inv2_diag[x + z][y + z + 1]++;
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = i; j < N; j++) {
			sum += inv2_vert[j][i];
			imos[j][i] += sum;
		}
		sum = 0;
		for (int j = 0; j < N - i; j++) {
			sum += inv2_diag[i + j][j];
			imos[i + j][j] += sum;
		}
	}
	int ret = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += imos[i][j];
			if (sum) ret++;
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 201816
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;

#define testcase            int t; cin>>t; while (t--)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define sc(a)               scanf("%lld",&a)
#define sc2(a,b)            scanf("%lld %lld",&a,&b)
#define pb                  push_back
#define all(x)              (x).begin(),(x).end()
#define reversed(s)         reverse(s.begin(), s.end())
#define asort(s)            sort(s.begin(), s.end())
#define dsort(s)            sort(s.begin(), s.end(),greater<ll>())
#define gtl(x)              getline(cin, (x))
#define PI                  acos(-1)
#define CLR(x, y)           memset(x, y, sizeof(x))
#define Precision(a)        cout << fixed << setprecision(a)
#define FasterIo            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                "\n"
#define MAXP                2000006
#define MOD                 10000007
#define EPS                 1e-7

template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}

bool cmp(pair<int , int>a, pair<int, int>b){
    return (a.first<b.first);
}
int main()
{
    FasterIo
    ll a, b, c, d, x, y, z, k, q, w,e,r;
    cin >> a >> b >> c >> d;
    x=a*c;
    y=a*d;
    z=b*c;
    k=b*d;
    q=max(x, y);
    r=max(z, k);
    if(q>r) cout << q << endl;
    else cout << r << endl;



    return 0;
}



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

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

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

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

	int a, b, h;
	
	cin >> a >> b >> h;

	cout << (a+b) * h / 2 << endl;
	
	return 0;
}

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

int main() {
    ll L, R;
    cin >> L >> R;
    priority_queue<ll, vector<ll>, greater<ll>> res;
    rep2l(i, L, R) {
        rep2l(j, i+1, R+1) {
            ll ans = ((i%2019)*(j%2019))%2019;
            if (ans == 0) {
                cout << ans << endl;
                return 0;
            }
            res.push(ans);
        }
    }
    cout << res.top() << endl;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line;
//		line = br.readLine();
//		System.out.println( reverseShift(line, (byte) 4) );
		while ( (line = br.readLine()) != null ) {
			System.out.println(decrypt(line));
		}

	}

	public static String decrypt(String line) {
		for (byte shift = 0; shift < 26; shift++) {
			String reverse = reverseShift(line, shift);
			String[] array = reverse.split("\\.| ");
			for (String str : array) {
				if (  str.equals("the") || str.equals("this") || str.equals("that")  ) {
					return reverse;
				}
			}
		}
		return "fxxk not find!";
	}

	// 'a' + 25 = 'z'
	// 'z' + 1 = 'a' + 26
	//          a,    b,   c, ... ,  x,  y,  z,
	// 'a'+n :  0,    1,   2,     , 23, 24, 25, 26,
	// 'a'-n :    , -25, -24, ... , -3, -2, -1,  0,
	private static String reverseShift(String line, byte shift) {
		char[] ca = line.toCharArray();
		for (int i=0; i < ca.length; i++) {
			if ( ca[i] != ' ' && ca[i] != '.' ) {
				if (ca[i] - shift >= 'a') {
					ca[i] = (char) (ca[i] - shift);
				} else { // ca[i] - shift < 'a'
					// ca[i] - shift = 'a' - n ??¨????????¨
					// ca[i] ??? ??¢?????????????????????????????????
					// n????????????????????\?????? (z:1??????)
					byte minus = (byte) (ca[i] - shift - 'a');
					ca[i] = (char) ('z' + 1 + minus);
				}
			}
		}
		return String.valueOf(ca);
	}
}

Measured memory_bytes: 24712
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  int a,b; cin >> a >> b;
  vector<int> v(4);
  v[a] = 1;
  v[b] = 1;
  rep1(i,3){
    if(v[i] == 0){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}



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

namespace Print_Test_Cases
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> input = new List<int>();

            while (true)
            {
                int temp = int.Parse(Console.ReadLine());
                if(temp == 0)
                {
                    break;
                }
                input.Add(temp);
            }

            for (int i = 0; i < input.Count; ++i)
            {
                Console.WriteLine("Case " + (i + 1) + ":" + " " + input[i]);
            }
        }
    }
}



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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

const ll 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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

ll N;
std::vector<P> ps;
std::set<P> S;
std::vector<std::vector<ll> > G;
std::vector<bool> used;

mint dfs( int v )
{
  mint ret = 1;

  used[v] = true;

  for( auto u : G[v] )
  {
    if( used[u] )
      continue;

    ret *= dfs(u);
  }

  ret += 1;

  return ret;
}

int main()
{
  scanf( "%lld", &N );

  rep( i, N )
  {
    ll X, D;
    scanf( "%lld%lld", &X, &D );
  
    ps.emplace_back( P( X, D ) );
  }

  std::sort( all(ps) );

  G.assign( N, std::vector<ll>() );
  used.assign( N, false );

  for( int i = N-1; i >= 0; --i )
  {
    ll x = ps[i].first, d = ps[i].second;

    while( !S.empty() && S.begin()->first < x+d )
    {
      G[i].emplace_back( S.begin()->second );
      S.erase( S.begin() );
    }

    S.emplace( P( x, i ) );
  }

  mint ans = 1;

  rep( i, N ) if( !used[i] )
    ans *= dfs(i);

  printf( "%lld\n", ans.x );

  return 0;
}

Measured memory_bytes: 24428
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int l[105];

int main(void)
{
	int n;
	int cnt = 0;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &l[i]);

	sort(l + 1, l + n + 1);

	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			for (int k = j + 1; k <= n; k++)
			{
				if (l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k])
				{
					cnt++;
				}
			}

	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 3828
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"


int main(int argc, char const *argv[]) {

  int NN, TT;
  std::cin >> NN>>TT;

  int ans_c = 2000;


  for (size_t i = 0; i < NN; i++) {
    int c, t;
    std::cin >> c>>t;
    if (t <= TT) {
      if (c <= ans_c) {
        ans_c = c;
      }
    }
  }

  if (ans_c == 2000) {
    std::cout << "TLE" << '\n';
  }else{
    std::cout << ans_c << '\n';

  }



  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static ArrayList<ArrayList<Integer>> graph = new ArrayList<>();;
    static int[] values;
    static int[] longest;
    static int[] ans;
    static boolean[] used;
    static int n;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
            graph.add(new ArrayList<>());
        }
        longest = new int[n + 1];
        Arrays.fill(longest, Integer.MAX_VALUE);
        longest[0] = 0;
        ans = new int[n];
        used = new boolean[n];
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
        search(0, 0);
        StringBuilder sb = new StringBuilder();
        for (int x : ans) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
    
    static void search(int idx, int max) {
        if (used[idx]) {
            return;
        }
        used[idx] = true;
        int left = 0;
        int right = n + 1;
        while (right - left > 1) {
            int m = (left + right) / 2;
            if (longest[m] < values[idx]) {
                left = m;
            } else {
                right = m;
            }
        }
        int save = longest[left + 1];
        max = Math.max(max, left + 1);
        longest[left + 1] = Math.min(longest[left + 1], values[idx]);
        ans[idx] = max;
        for (int x : graph.get(idx)) {
            search(x, max);
        }
        longest[left + 1] = save;
    }
}

Measured memory_bytes: 98288
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]

dp = [[0] * (w+1) for i in range(n)]

for i in range(n):
    for j in range(w+1):
        if j < wv[i][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]] + wv[i][1])

print(dp[-1][-1])

Measured memory_bytes: 120044
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int mod=998244353;
const int lim=16,maxn=(1<<20)+5,N=110;
int F[lim+1][maxn],G[lim+1][maxn];
int dp[10][N];int g[N][N];
int a[N];char s[N];
ll p[N],c[N][N];
int n;

void work(int K){
	int i,j,k;int cur,x;
	rep(i,0,(1<<K)-1){
		rep(j,1,K/2)	if(K%j==0){
			x=i;cur=p[j];rep(k,1,K/j)	cur&=x,x>>=j;		
			G[K][i]=(G[K][i]+F[j][cur])%mod;
		}
		//F[K][i]=(F[K][i]+1ll*F[K-1][i>>1]*((i&1)+1))%mod;
		rep(j,1,K)	if(G[j][i&p[j]])	F[K][i]=(F[K][i]+1ll*G[j][i&p[j]]*F[K-j][i>>j])%mod;
	}
}	

void init(){
	int i;
	rep(i,1,50)	p[i]=(1ll<<i)-1;
	F[0][0]=1;
	G[1][0]=F[1][0]=1;F[1][1]=G[1][1]=2;
	rep(i,2,lim)	work(i);
}

int solve(int K,ll w,int d){
	if(K<=lim)	return F[K][w];
	int i,j,k;ll cur;int x;int opt;
	//memset(dp[d],0,(K+1)*sizeof(int));
	rep(i,0,K)	dp[d][i]=0;
	dp[d][0]=1;
	rep(i,0,K-1) if(dp[d][i]){
		if(K-i<=lim){dp[d][K]=(dp[d][K]+1ll*dp[d][i]*F[K-i][w>>i])%mod;continue;}
		opt=(w>>i)&1;
		dp[d][i+1]=(dp[d][i+1]+1ll*dp[d][i]*(opt+1))%mod;
		rep(j,1,(K-i)>>1){		
			for(cur=(w&p[i+j])>>i,x=i+j,k=2;k<=(K-i)/j;k++){
				cur&=(w&p[x+j])>>x;x+=j;
				dp[d][x]=(dp[d][x]+1ll*dp[d][i]*solve(j,cur,d+1))%mod;
			}
		}
	}
	return dp[d][K];
}

int getG(int l,int r){
	if(r-l+1<=lim)	return G[r-l+1][c[l][r]];
	int len=r-l+1;int ret=0;int i;
	ll cur;int x;
	rep(i,1,len/2)	if(len%i==0){
		for(cur=p[i],x=l;x<=r;x+=i)	cur&=c[x][x+i-1];
		ret=(ret+solve(i,cur,1))%mod;
	}
	return ret;
}		

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,j;
	init();
	scanf("%s",s+1);n=strlen(s+1);
	rep(i,1,n)	a[i]=s[i]-'0';
	for(i=n;i;i--)	rep(j,i,n)	c[i][j]=(c[i+1][j]<<1)+(a[i]&1);
	rep(i,1,n)	rep(j,i,n)	g[i][j]=getG(i,j);
	dp[0][0]=1;
	rep(i,0,n-1) rep(j,i+1,n) dp[0][j]=(dp[0][j]+1ll*dp[0][i]*g[i+1][j])%mod;
	printf("%d\n",dp[0][n]);
}
			
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 67840
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let mut divisors = vec![0; 100];
    let n: usize = sc.read();
    for mut i in 1..(n + 1) {
        for p in 2..100 {
            if i % p == 0 {
                while i % p == 0 {
                    i /= p;
                    divisors[p] += 1;
                }
            }
        }
    }

    let mut dp = vec![0; 76];
    dp[1] = 1;
    for &c in divisors.iter() {
        let mut next = vec![0; 76];
        for c in 0..(c + 1) {
            for i in 0..76 {
                if i * (c + 1) <= 75 {
                    next[i * (c + 1)] += dp[i];
                }
            }
        }
        dp = next;
    }
    println!("{}", dp[75]);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,m;
string a[60];
string b[60];
bool match(int x,int y)
{
    int i,j;
    for(i=0;i<m;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[x+i][y+j]!=b[i][j])
                return false;
        }
    }
}

int main()
{
   int i,j;
   cin>>n>>m;

   for(i=0;i<n;i++)
   {
     cin>>a[i];
   }
   for(i=0;i<m;i++)
   {
       cin>>b[i];
   }
   bool f=false;
   for(i=0;i<=n-m;i++)
   {
      for(j=0;j<=n-m;j++)
      {
         if(match(i,j))
            f=true;
      }
   }
   if(f==true)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array([0] + [ir() for _ in range(N)] + [0])
max_left = np.maximum.accumulate(A)
max_rihgt = np.maximum.accumulate(A[::-1])[::-1]
answer = np.zeros(N+1, np.int64)
answer[1:] = np.maximum(max_left[:-2], max_rihgt[2:])
print('\n'.join(answer[1:].astype(str)))


Measured memory_bytes: 60148
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		br.close();

		Eratosthenes era = new Eratosthenes(n);
		long ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += (long) i * getDivCnt(era, i);
		}
		System.out.println(ans);
	}

	static class Eratosthenes {
		int[] div;

		public Eratosthenes(int n) {
			if (n < 2) return;
			div = new int[n + 1];
			div[0] = -1;
			div[1] = -1;
			int end = (int) Math.sqrt(n) + 1;
			for (int i = 2; i <= end; i++) {
				if (div[i] == 0) {
					div[i] = i;
					for (int j = i * i; j <= n; j+=i) {
						if (div[j] == 0) div[j] = i;
					}
				}
			}
			for (int i = end + 1; i <= n; i++) {
				if (div[i] == 0) div[i] = i;
			}
		}

		public Map<Integer, Integer> bunkai(int x) {
			Map<Integer, Integer> soinsu = new HashMap<>();
			while (x > 1) {
				Integer d = div[x];
				if (soinsu.containsKey(d)) {
					soinsu.put(d, soinsu.get(d) + 1);
				} else {
					soinsu.put(d, 1);
				}
				x /= d;
			}
			return soinsu;
		}

		public boolean isSosuu(int x) {
			return div[x] == x;
		}
	}

	static int getDivCnt(Eratosthenes era, int val) {
		Map<Integer, Integer> soinsu = era.bunkai(val);
		int cnt = 1;
		for (int key : soinsu.keySet()) {
			cnt *= soinsu.get(key) + 1;
		}
		return cnt;
	}
}


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

int main() {
    map<string,int> cnt;
    string s,ans1,ans2;
    int mx1=0,mx2=0;
    while (cin>>s) {
        cnt[s]++;
        if (cnt[s]>mx1) {
            mx1=cnt[s];
            ans1=s;
        }
        if (s.size()>mx2) {
            mx2=s.size();
            ans2=s;
        }
    }
    cout<<ans1<<' '<<ans2<<endl;
    return 0;
}


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

int main() {
    int x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    
    int i, temp;
    long long int ans = 0;
    
    priority_queue<int, vector<int>, greater<int>> A;
    priority_queue<int, vector<int>, greater<int>> B;
    priority_queue<int> C;
    
    for(i=0; i<a; i++) {
        cin>>temp;
        A.push(temp);
    }
    
    for(i=0; i<b; i++) {
        cin>>temp;
        B.push(temp);
    }
    
    for(i=0; i<c; i++) {
        cin>>temp;
        C.push(temp);
    }
    
    while(A.size() != x) {
        A.pop();
    }
    
    while(B.size() != y) {
        B.pop();
    }
    
    while(!C.empty()) {
        if (A.top() >= C.top()) {
            if (B.top() >= C.top()) {
                break;
            }
            else {
                B.pop();
                temp = C.top();
                B.push(temp);
                C.pop();
            }
        }
        else {
            if (B.top() >= C.top()) {
                A.pop();
                temp = C.top();
                A.push(temp);
                C.pop();
            }
            else {
                if (A.top() < B.top()) {
                    A.pop();
                    temp = C.top();
                    A.push(temp);
                    C.pop();
                }
                else {
                    B.pop();
                    temp = C.top();
                    B.push(temp);
                    C.pop();
                }
            }
        }
    }
    
    for(i=0; i<x; i++) {
        ans += A.top();
        A.pop();
    }

    for(i=0; i<y; i++) {
        ans += B.top();
        B.pop();
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1784
def enough(t):
    cnt = 0
    for h in h_list:
        if h > b*t:
            cnt += -(-(h-b*t)//c)
    if cnt <= t:
        return True
    else:
        return False

n, a, b = map(int,input().split())
c = a - b
h_list = [int(input()) for _ in range(n)]
h_list.sort()
left = 0
right = -(-h_list[-1]//b)
while right - left > 1:
    mid = -(-(left + right)//2)
    if enough(mid):
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 7384
from collections import Counter
N = int(input())
A = list(map(int ,input().split()))
C = Counter(A)
MAXD = 30
B = [('0' * MAXD + bin(a)[2:])[-30:] for a in A]

ps = []
res = True
for i in range(MAXD):
    bs = list(b[i] for b in B)
    c = Counter(bs)
    if c['0'] == N:
        continue
    if c['0'] == N // 3:
        if N % 3 == 0:
            if len(ps) != 0:
                if all(p == b for (b, p) in zip(bs, ps)):
                    continue
                bc = Counter(int(p + b, 2) for (b, p) in zip(bs, ps))
                if c[0] == 0 and c[1] == c[2] == c[3]:
                    continue
            ps = bs.copy()
            continue
    res = False
    break

print('Yes' if res else 'No')


Measured memory_bytes: 20620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<int, int>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
    ll N; cin >> N;
    vector<pll> A(N);
    for (int i = 0; i < N; ++i){
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin(), A.end(), greater<pll>());

    vector<vector<ll>> dp(N+1, vector<ll>(N+1));

    for (ll i = 0; i < N; i++){
        for (ll j = 0; i+j < N; j++){
            dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(A[i+j].first * (A[i+j].second - i)));
            dp[i][j+1] = max(dp[i][j+1], dp[i][j] + abs(A[i+j].first * (N-1-j - A[i+j].second)));
        }
    }
    ll ans = 0;
    for (int i = 0; i <= N; i++){
        ans = max(ans, dp[i][N-i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 34656
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e12
#define MOD 1000000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b)  {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  div(T a, T b)     {return ((a+b-1)/b);}
template<typename T> inline bool eoVerify(T a)     {return (!(a&1)? true : false );}

/***********************
* O(1)                 *
* O(logN)              *
* O(N)                 *
* O(NlogN)             *
* O(N^2)               *
* O(N^3)               *
* O(k^N)               *
* O(N!)                *
************************/

int main(){
    string str; cin >> str;
    rep(0,str.size()) str[i] = 'x';
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 3612
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W, '.'));
    rep(i, H) {
        rep(j, W) {
            cin >> a.at(i).at(j);
        }
    }

    vector<bool> row(H, false);
    vector<bool> col(W, false);

    rep(i, H) {
        rep(j, W) {
            if (a.at(i).at(j) == '#') {
                row.at(i) = true;
                col.at(j) = true;
            }
        }
    }

    rep(i, H) {
        rep(j, W) {
            if(row.at(i) == true && col.at(j) == true) {
                cout << a.at(i).at(j);
            }
        }
        if(row.at(i) == true) cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char s[101];
    cin.getline(s,101);
    int n=strlen(s),nr=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            nr++;
    }
    if(nr!=0)
        cout<<nr;
    else
        cout<<0;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int k,x,i;

	scanf("%d%d",&k,&x);
	for(i=0;i<2*k-1;i++){
		if(i<2*k-1)
			printf("%d ",x-k+1+i);
		else if(i==2*k-1)
			printf("%d ",x);
		else
			printf("%d ",x-k+1+i);
	}
	return 0;
}

Measured memory_bytes: 128
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN   PIC X(3).
01 a    PIC 9(1).
01 b    PIC 9(1).
01 n    PIC 9(1).
01 i    PIC 9(2).
01 ans  PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
    MOVE b TO n
  ELSE
    MOVE a TO n
    MOVE b TO a
  END-IF.
  PERFORM VARYING i FROM 1 BY 1 UNTIL n < i
    MOVE a TO ans(i:1)
  END-PERFORM.
  DISPLAY ans(1:n).
  STOP RUN.


Measured memory_bytes: 764
#include<stdio.h>

void swap(int* a,int* b);
void PRINT(int* A, int N);

int main(void){
	int N, i, j, minj,n=0;
	int flag=1, n1=0, n2=0;
	
	scanf("%d",&N);
	int selectionSort[N];
	for(i=0;i<N;i++){
		scanf("%d", &selectionSort[i]);
	}
	
	for(i=0;i<N;i++){
		minj = i;
		for(j=i;j<N;j++){
			if(selectionSort[j] < selectionSort[minj]){
				minj = j;
			}
		}
		if(i!=minj){
			swap(&selectionSort[i],&selectionSort[minj]);
			n++;
		}
	}
	
	PRINT(selectionSort,N);
	printf("%d\n",n);
	
	return 0;
}

void swap(int* a,int* b){
	int temp;
	temp=*a;
	*a=*b;
	*b=temp;
}

void PRINT(int* A, int N){
	int i;
	printf("%d",A[0]);
	for(i=1;i<N;i++){
		printf(" %d",A[i]);
	}
	printf("\n");
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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 ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
	}
    rep(i,n-1){
        for(int j=i+1; j<n;j++){
            ans += a[i] * a[j];
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N, K = map(int, input().split())
X = list(map(int, input().split()))

# x[0], x[-1]
def get_len(x0, xm1):
    left = abs(x0) + abs(xm1-x0)
    right = abs(xm1) + abs(xm1-x0)
    return min(left, right)

count = INF
for i in range(N-K+1):
    if X[i] > 0:
        X[i] = 0

    l = get_len(X[i], X[i+K-1])
#    print(X[i], X[i+K-1], l)
    count = min(count, l)

print(count)

Measured memory_bytes: 14168
from collections import deque
n = int(input())
s = list(input())
d = deque(s)
l, r = 0, 0
for i in range(n):
    if l == r and s[i] == ")":
        d.appendleft("(")
    elif s[i] == ")":
        r += 1
    else:
        l += 1
s = "".join(list(d))
print(s + ")" * max(0, l - r))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> cnt(n+1);
   f(i,1,n){
      int x;
      cin >> x;
      cnt[x]++;
   }
   f(i,1,n+1){
      cout << cnt[i] << '\n';
   }
   return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll n;
  ll k;
  cin >> n >> k;
  ll a[n];
  REP(i,n) {
    cin >> a[i];
    a[i]--;
  }

  ll nv = 0;
  if (k <= 200000) {
    REP(i,k) {
      nv = a[nv];
    }
    COUT(nv+1);
    return 0;
  }

  vector<ll> x;
  vector<ll> hist(n,0);
  REP(i,k) {
    x.push_back(nv);
    hist[nv]++;
    if (hist[nv] == 2) { break; }
    nv = a[nv];
  }

  ll loop = 0;
  vector<ll> loopx;
  for (ll i = x.size()-2; i >= 0; i--) {
    loop++;
    loopx.push_back(x[i]);
    if (x[i] == nv) {
      break;
    }
  }
  ll beforeloop = x.size() - 1 - loop;
  reverse(loopx.begin(), loopx.end());
  /*
  for (auto v : x) {
    cout<< "v: " << v << endl;
  }
  for (auto vv : loopx) {
    cout<< "vv: " << vv << endl;
  }
  COUT(beforeloop);
  COUT(loop);
  COUT((k - beforeloop) % loop);
  */
  COUT(loopx[ (k - beforeloop) % loop]+1);
  return 0;
}

Measured memory_bytes: 9468
#include <stdio.h>
#include <string.h>
int main(){
  int n;
  int tmp;
  int ans = 0;

  scanf("%d", &n);

  if(n /1000 == 2){
    ans++;
  }

  tmp = n / 1000;
  if((n - tmp*1000)/ 100 == 2){
    ans++;
  }

  tmp = n / 100;
  if((n - tmp*100) / 10 == 2){
    ans++;
  }

  tmp = n / 10;
  if((n - tmp*10) == 2){
    ans++;
  }

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


}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  cin>>S;
  int ans=(int)(S.size())*((int)(S.size())-1)/2+1;
  vector<int> A(26);
  for(char c:S){
    ans-=A[c-'a'];
    A[c-'a']++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

int main(){
    fast_io
    //dbl_io(10);
    ll n;
    cin >> n;
    cout << (n + 1) / 2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());

    ll ans = 0;

    if (n%2){
        rep(i, (n-1)/2){
            ans += 2*a[i+1];
        }
        ans -= a[(n-1)/2];
        ans += a[0];
    }else{
        rep(i, n/2-1){
            ans += 2*a[i+1];
        }
        ans += a[0];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
N,M,X = map(int,input().split())
A = list(map(int, input().split()))
ans1 = 0
for i in range(X,N):
    if i in A:
        ans1 += 1
ans2 = 0
for i in range(X,0,-1):
    if i in A:
        ans2 += 1
print(min(ans1,ans2))


Measured memory_bytes: 38256