akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int size = 1_000_000;
        int[] arr = new int[size+1];

        for(int i = 1; i <= n; i++)
        	arr[i] = i;

        for(int i = 2; i <= n; i++) {
        	if(arr[i] == -1) continue;
        	for(int j = i*2; j <= size; j=j+i) {
        		arr[j] = -1;
        	}
        }
        for(int i = n; i <= size; i++) {
        	if(arr[i] != -1) {
        		System.out.println(i);
        		return;
        	}
        }
    }
}


Measured memory_bytes: 27732
#include <iostream>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, c, k, t[100010];
    cin >> n >> c >> k;
    for (int i = 0; i <  n; i++) cin >> t[i];
    
    sort(t, t + n);
    
    ll bus = 0, wt = 0, limit;
    for (int i = 0; i < n; i++) {
        if (wt > 0 && t[i] - limit > k) {
            bus++;
            wt = 0;
        }
        
        if (wt == 0) {
            limit = t[i];
            wt++;
            if (wt == c) {
                bus++;
                wt = 0;
            }
        }
        else {
            wt++;
            if (wt == c) {
                bus++;
                wt = 0;
            }
        }
    }
    if (wt > 0) bus++;
    
    cout << bus << endl;
    
}


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

int main(void)
{
	int a, b;
	
	cin >> a >> b;
	
	if(a < b){
		cout << "a < b";
	}
	else if (a > b){
		cout << "a > b";
	}
	else {
		cout << "a == b";
	}
	
	cout << endl;
	
	return (0);
}

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

using namespace std;

int main() 
{
    int n, m, a, b, c, i;
    scanf("%d", &n);
    
    vector<int> v;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &m);
        v.push_back(m);
    }
    
    scanf("%d", &m);
    
    for(i = 0; i < m; i++)
    {
        scanf("%d %d %d", &a, &b, &c);
        rotate(v.begin() + a, v.begin() + b, v.begin() + c);
    }
    
    for(i = 0; i < n-1; i++)
        printf("%d ", v[i]);
    printf("%d\n", v[i]);
    
    return 0;
}


Measured memory_bytes: 3296
#include <stdio.h>

int swap(int *x, int *y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;

	return (0);
}

int bsort(int *data, int last)
{
	int count = 0;
	for (int i = 0; i < last; i++){
		if (data[i] > data[i + 1]){
			swap(data + i, data + i + 1);
			count++;
		}
	}
	return (count);
}

int main()
{
	int array[128];
	int n, i;

	while (scanf("%d", &n), n){
		for (i = 0; i < n; i++){
			scanf("%d", array + i);
		}
		int sum = 0;
		for (i = 1; i < n; i++){
			sum += bsort(array, n - i);
		}

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

	return (0);
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

vector<int> blue;
vector<int> red;
vector<int> redpair;
vector<int> v;
vector<vector<int> > c;
int m = 0;
int n = 0;


int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y,x%y);
}

bool match(int x){
    if(x == -1){
        return 1;
    }
    for(int i = 0;i < n;i++){
        if(c[x][i] == 1 && v[i] == 0){
            v[i] = 1;
            if(match(redpair[i])){
                redpair[i] = x;
                return 1;
            }
        }
    }
    return 0;
}


int main(){

    while(cin >> m >> n){
        if(m == 0 && n == 0){
            break;
        }
        blue.clear();
        red.clear();
        redpair.clear();
        v.clear();
        c.clear();
        for(int i = 0;i < m;i++){
            int tmp = 0;
            cin >> tmp;
            blue.push_back(tmp);
        }
        for(int i = 0;i < n;i++){
            int tmp = 0;
            cin >> tmp;
            red.push_back(tmp);
            redpair.push_back(-1);
            v.push_back(0);
        }
        for(int i = 0;i < m;i++){
            c.push_back(vector<int>());
            for(int j = 0;j < n;j++){
                c[i].push_back(gcd(blue[i],red[j]) != 1);
            }
        }
        int ans = 0;
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                v[j] = 0;
            }
            if(match(i)){ans++;}
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2156
S = input()
if S =='SUN':
  print("7")
elif S == 'MON':
  print("6")
elif S == 'TUE':
  print("5")
elif S == 'WED':
  print("4")
elif S == 'THU':
  print("3")
elif S == 'FRI':
  print("2")
elif S == 'SAT':
  print("1")

Measured memory_bytes: 3064
// AtCoder Beginner Contest 090
// B - Palindromic Numbers
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  
  int count = 0;
  for (int i = a; i <= b; i++) {
    if (i/10000 == i%10 && (i/1000)%10 == (i/10)%10) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  long long ans = 0;
  for (int i = 1; i < N; i++){
    ans += A[i / 2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

//----------------------------------
//----------------------------------

signed main()
{
    ios::sync_with_stdio(false);
        string s;
        cin >> s;
        cout << s.substr(0, 4) << ' ' << s.substr(4, 8) << '\n';
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,i,j,k,l;
    cin>>a;
    b=a/500;
    c=(a%500)/5;
    d=(b*1000);
    e=(c*5);
    cout<<d+e<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;cin>>S;
  if(S=="SSS"){
    cout<<0<<endl;
  }
  else if(S=="RRR"){
    cout<<3<<endl;
  }
  else if((S[0]=='R'&&S[1]=='R')||(S[1]=='R'&&S[2]=='R')){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int N, X,L[100000], B, D, judge1, judgex[100000], judge2, M, i, j;
long long Ans = 1, judgey[100000];
string S;
int n = 0;

int main() {
	cin >> N >> X;
	for (i = 0; i < N; i++) {
		cin >> L[i];
		if(i>0)
		L[i] = L[i] + L[i - 1];
	}
	for (i = 0; i < N; i++) {
		if (X >= L[i])
			Ans += 1;
	}

	if (Ans < N + 1)
		cout << Ans;
	else
		cout << N + 1;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>

bool valid(int a, int b, int c) {
    return a <= b + c && b <= c + a + 1 && c <= a + b + 1;
}

void calc(int rear, int front, int west, int east, int north, int south, char* start, char* end) {
    bool same = true;
    for (char* s = start; s < end; s++) {
        int a = rear + front;
        int b = west + east;
        int c = north + south;
        char y;
 
        int temp = rear;
        if (east > 0 && valid(b - 1, c, a)) {
            rear = east - 1;
            east = front;
            front = west;
            west = temp;
            y = 'E';
        } else if (north > 0 && valid(c - 1, a, b)) {
            rear = north - 1;
            north = front;
            front = south;
            south = temp;
            y = 'N';
        } else if (south > 0 && valid(c - 1, a, b)) {
            rear = south - 1;
            south = front;
            front = north;
            north = temp;
            y = 'S';
        } else {
            rear = west - 1;
            west = front;
            front = east;
            east = temp;
            y = 'W';
        }

        if (same) {
            char x = *s;
            if (x < y) {
                return;
            }
            same = x == y;
        }
        *s = y;
        start++;
    }
}

char* find(int target[6], int limit) {
    char* buffer = new char[limit + 1];
    char* end = buffer + limit;
    std::memset(buffer, 'Z', limit);
    *end = '\0';

    std::sort(target, target + 6);
    do {
        if (valid(target[0] + target[1], target[2] + target[3], target[4] + target[5])) {
            calc(target[0], target[1], target[2], target[3], target[4], target[5], buffer, end);
        }
    } while (std::next_permutation(target, target + 6));

    return buffer;
}

int main() {
    int target[6];
    while (true) {
        bool nonzero = false;
        for (int i = 0; i < 6; i++) {
            std::cin >> target[i];
            nonzero = nonzero || target[i];
        }
        if (!nonzero) {
            break;
        }

        int p, q;
        std::cin >> p >> q;

        char* result = find(target, q);
        if (result[0] == 'Z') {
            std::cout << "impossible" << std::endl;
        } else {
            std::cout << &result[p - 1] << std::endl;
        }
        delete[] result;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=100001;
typedef long long ll;
ll H,W,A,B,fac[2000010];
void create()
{
	fac[1]=1;
	for(int i=2;i<=2000001;i++)
		fac[i]=fac[i-1]*i,fac[i]%=mod;
	return;
}
ll expand(ll a,ll b,ll &x,ll &y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    ll r=expand(b,a%b,x,y);
    ll t=y;
    y=x-(a/b)*y;
    x=t;
    return r;
}
ll ways(ll x1,ll y1,ll x2,ll y2)
{
	if(y2==y1 || x2==x1)
		return 1;
	ll x=fac[abs(y2-y1)+abs(x2-x1)];
	ll y=fac[abs(y2-y1)];
	ll z=fac[abs(x2-x1)];
	ll t=(y*z%mod+mod)%mod;
	ll x0=0,y0=0;
	expand(t,mod,x0,y0);
	ll answer=x*x0%mod;
	answer=(answer%mod+mod)%mod;
	return answer;
}
int main()
{
	scanf("%lld %lld %lld %lld",&H,&W,&A,&B);
	create();
	ll ans=0;
	for(int i=B+1;i<=W;i++)
		ans+=ways(A,i,1,W)*ways(H,1,A+1,i),ans%=mod;
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  ll n = s.size();
  if(s[n-1] == '3') cout << "bon" << endl;
  else if(s[n-1] == '0' || s[n-1] == '1' || s[n-1] == '6' || s[n-1] == '8') cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int i,ans=0;
	cin>>s;
	for(int i=0;i<s.size()-1;i++)
	if(s[i]!=s[i+1]) ans++;
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> L(N);
    for(int i = 0; i < N; i++)
    {
        cin >> L.at(i);
    }

    //Lを降順にソート
    sort(L.begin(), L.end(), greater<int>());

    int len = 0;
    for(int i = 0; i < K; i++)
    {
        len += L.at(i);
    }

    cout << len;

    return 0;
}

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

#define endl '\n'
#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll int n,d,t,s;
	cin >> d >> t >> s;
	n=t*s;
	if(d>n) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  cout << a[2] * 10 + a[1] + a[0] << endl;
}

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

int n;
vector<int> G[100];

int DFS(int from, int prev) {
  int mx = 0;
  for (int to : G[from]) {
    if (to == prev) continue;
    mx = max(mx, DFS(to, from) + 1); 
  }
  return mx;
}

vector<int> centers() {
  map<int, vector<int>> mp;
  for (int i = 0; i < n; ++i) {
    int dist = DFS(i, -1);
    mp[dist].push_back(i);
  }
  cout << mp.begin()->first + (mp.begin()->second.size() == 1) << ' ';
  return mp.begin()->second;
}

int D[100];
int C[100];
void cat(int from, int prev, int depth) {
  D[from] = depth;
  int cnt = 0;
  for (int to : G[from]) {
    if (to == prev) continue;
    ++cnt;
    cat(to, from, depth + 1);
  }
  C[from] = cnt;
}

long sub(vector<int> cs) {
  if (cs.size() == 1) {
    cat(cs[0], -1, 0);
  } else {
    cat(cs[0], cs[1], 0);
    cat(cs[1], cs[0], 0);
  }
  map<int, int> mp;
  for (int i = 0; i < n; ++i) {
    mp[D[i]] = max(mp[D[i]], C[i]);
  }
  
  long ans = 1;
  for (auto p : mp) {
    ans *= p.second == 0 ? 1 : p.second;
  }
  return ans * cs.size();
}

int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<int> cs = centers();
  
  long ans;
  if (cs.size() == 1) {
    ans = sub(cs);
    for (int to : G[cs[0]]) {
      vector<int> v(cs);
      v.push_back(to);
      ans = min(ans, sub(v));
    }
  } else {
    ans = sub(cs);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import bisect



def resolve():
    N = int(input())
    A=[int(i) for i in input().split()]
    B=[int(i) for i in input().split()]
    C=[int(i) for i in input().split()]

    A.sort()
    B.sort()
    C.sort()

    B2=[bisect.bisect_left(A,i)  for i in B]

    for i in range(1,N):
        B2[i]+=B2[i-1]
    C2=[bisect.bisect_right(B,i-1) for i in C]

    print(sum([B2[i-1]  for i in C2 if i != 0 ]))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 115120
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

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

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

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) {
  return stream << p.first << " " << p.second;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (const T& x: vec) out << x << ' ';
  return out;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for(auto& x: vec) in >> x;
  return in;
}
// @formatter:on


class DWaterBottle {
public:
  ld a, b, x;
  
  ld f() {
    if (a * a * b / 2.0 <= x) {
      return atan(2 * (a * a * b - x) / (a * a * a));
    }
    return PI / 2 - atan(2 * x / (a * b * b));
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    cin >> a >> b >> x;
    cout << fixed << setprecision(10) << f() * 180.0 / PI << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DWaterBottle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3788
from sys import stdin
input = stdin.readline
import copy as cp
from collections import deque

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

N, T = map(int, input().rstrip().split())
A = list(map(int, input().rstrip().split()))

mi = VI(N)
ma = VI(N)

mi[0] = A[0]
ma[N-1] = A[N-1]

for i in range(1, N):
  mi[i] = min(A[i], mi[i-1])

for i in range(N-2, -1, -1):
  ma[i] = max(A[i], ma[i+1])

t = T // 2

max_benefit = 0
for i in range(N-1):
  max_benefit = max(max_benefit, ma[i+1]-mi[i])

s = set([])
s.add(A[N-1])
cnt = 0
for i in range(N-2, -1, -1):
  a = A[i]
  if (a+max_benefit) in s:
    cnt += 1
  s.add(a)

print(cnt)


Measured memory_bytes: 70260
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<char> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  char ans=v[0];
  auto calc=[](char a,char b){return a=='T'?b:'T';};
  for(int i=1;i<n;i++) ans=calc(ans,v[i]);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3208
#include<stdio.h>
#include<string.h>
int main()
{
    int m,i,j,count=0,a[100];
    scanf("%d",&m);
    for(i=0; i<m; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<=m-1; i++)
    {
        for(j=m-1; j>=i+1; j--)
        {
            if(a[j]<a[j-1])
            {
                int temp;
                temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
                count++;
            }
        }
    }
    for(i=0; i<m-1; i++)
        printf("%d ",a[i]);
    printf("%d",a[m-1]);
    printf("\n");
    printf("%d\n",count);
}


Measured memory_bytes: 2096
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    ll n, m;
    cin >> n >> m;

    if(2 * n < m){
        ll rest = m - 2 * n;
        ll ans = n;
        ans += rest / 4;
        cout << ans << endl;
    } else {
        cout << m / 2 << endl;
    }

}

Measured memory_bytes: 256
#if By_CYJian

AGC039 A

#endif

#include <bits/stdc++.h>

using namespace std;

#define FILE(Name) freopen(Name".in", "r", stdin), freopen(Name".out", "w", stdout)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline T gcd(T&a, T b) { return !b ? a : gcd(b, a % b); }
typedef unsigned uit;
typedef long long ll;
typedef double db;

// 看题目取用
// const int mod = 2999999; // for Hash
// const int mod = 4999999; // for Hash
// const int mod = 19491001;
// const int mod = 19260817;
// const int mod = 104857601;
// const int mod = 998244353;
// const int mod = 998244853;
// const int mod = 1004535809;
const int mod = 1000000007;

template<typename T> const T Mod(T x) { return x >= mod * 2 ? x % mod : (x >= mod ? x - mod : x); }
template<typename T> const void Add(T&a, T b) { a = Mod(a + b); }

char s[120];

int main() {
#ifdef LOCAL
	FILE("a");
#endif
	gstr(s); int k; gi(k);
	int len = strlen(s);
	ll res = 0;
	int l = 0, lc = 0, bg = 0;
	for(int i = 0; i < len; i++) {
		if(s[i] == lc) ++l;
		else {
			if(l && !bg) bg = l;
			res += 1LL * k * (l >> 1);
			lc = s[i];
			l = 1;
		}
	}
	if(l == len)
		res = 1LL * k * len >> 1;
	else {
		if(s[len - 1] == s[0]) {
			res -= 1LL * (bg >> 1) * (k - 1);
			res += 1LL * ((bg + l) >> 1) * (k - 1) + (l >> 1);
		} else res += 1LL * (l >> 1) * k;
	}
	print(res), pc('\n');
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]" << endl; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> pl, mn;
    rep(i,N){
        cin >> A[i];
        if(A[i] >= 0)pl.emplace_back(A[i]);
        else mn.emplace_back(A[i]);
        A[i] = abs(A[i]);
    }
    if(mn.size() % 2 == 0){
        cout << SUM(A) << endl;
    }
    else{
        cout << SUM(A) - 2* *min_element(all(A)) << endl;
    }
}


Measured memory_bytes: 5400
#include <iostream>

 

using namespace std;

 

int main() 
{
    int i, x;
    for(i=1; i<=10000; i++)
    {  
        cin >> x;
        if ( x==0 )
          break;
        cout << "Case" << " " << i << ": " << x << endl;
        
       
      
    }
}


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

// 縦 H  マス、横 W マスの盤面があります。 
// この盤面の左上隅のマスに角行の駒が置かれています。 
// 駒が 0 回以上の好きな回数の移動を繰り返して到達できるマス目は何個あるでしょうか？
// 1000000000 1000000000

int main()
{
	unsigned long long H, W, ans;
	cin >> H >> W;
	
	if( H < 2 || W < 2) {
		ans = 1;
	} else {
		ans = (H/2 + H%2)*(W/2 + W%2);
		ans += (H/2)*(W/2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

int main(){
    int n,k; cin>>n>>k;
    ll x[100001];
    FOR(i,0,n) cin>>x[i];
    ll ans=1e18;
    FOR(i,0,n-k+1){
        ll a=x[i],b=x[i+k-1];
        ans=min(ans,b-a+min(abs(a),abs(b)));
    }
    co(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 1e5 + 5;
const ll mod = 1000000007 ;
using namespace std;


int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

	// cin >> tc;


	while (tc--) {

		ll n, i, j, r, x, y;
		ll k;
		cin >> k;
		string s;
		cin >> s;

		if (s.length() <= k) {
			cout << s << endl;
		}
		else {
			for (i = 0; i < k; i++) {
				cout << s[i];
			}
			cout << "...";

			cout << endl;
		}



	}

}

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

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = K;
  for (int i = 0; i < N - 1; i++) {
    ans *= K - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
n_temp = n
index_pochi = []
eiji_list = [chr(ord('a') + i) for i in range(26)]
while(True):
    eiji = eiji_list[(n_temp-1)%26]
    index_pochi = [eiji] + index_pochi
    if int((n_temp-1)/26) == 0:
        break
    n_temp = int((n_temp-1)/26)
print("".join(index_pochi))

Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A);
	int cnt = 1;
	int ans = 0;
	rep(i, N - 1) {
		if (A[i] != A[i + 1]) {
			ans += (cnt % 2);
			cnt = 1;
		}
		else {
			cnt++;
		}
	}
	ans += (cnt % 2);
	cout << ans << endl;
}




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

using namespace std;

int n, m, k, Min = (((1 << 30) - 1) << 1) + 1;

int main()
{
#ifdef CraZYali
	freopen("b.in", "r", stdin);
	freopen("b.out", "w", stdout);
#endif
	cin >> n >> m;
	for (register int i = 1; i <= n ; i ++)
	{
		scanf("%d", &k);
		m -= k;
		Min = min(Min, k);
	}
	printf("%d\n", n + m / Min);
	return 0;
}


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

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

    vector<int> A(N+1, K-Q);
    for (int r = 0; r < Q; r++) {
        uint i; cin >> i;
        ++A[i];
    }

    for (size_t i=1; i<A.size(); i++) {
        if (A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}



Measured memory_bytes: 1024
#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;
	cout<<(n+1)*n/2-n<<endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl
#define all(x) x.begin(), x.end()
#define endl "\n"

const int M = 998244353, N = 2e5 + 3;
vll fact(N), inv_fact(N);

ll bpow(ll base, int exp)
{
    if (exp == 0)
        return 1ll;
    ll ans = bpow(base, exp / 2);
    ans = (ans * ans) % M;
    if (exp % 2)
        ans = (ans * base) % M;
    return ans;
}
void pre()
{
    fact[0] = 1;
    for (int i = 1; i < N; i++)
        fact[i] = (fact[i - 1] * i) % M;
    inv_fact[N-1] = bpow(fact[N-1],M-2);
    for(int i=N-2;i>=0;i--)
    {
        inv_fact[i] = ((i+1)*inv_fact[i+1])%M;
    }
}
inline ll ncr(int n, int r)
{
    return (((inv_fact[r]*inv_fact[n-r])%M)*fact[n])%M;
}
void print(vll v,int n)
{
    cout<<"DEBUG\n";
    for(int i=0;i<n;i++)
        cout<<v[i]<<" ";
    cout<<endl;
}

void solve()
{
    ll x;
    cin>>x;
    for(ll a = -1000;a<=1000;a++)
    {
        for(ll b = -1000;b<=1000;b++)
        {
            if((a*a*a*a*a)-(b*b*b*b*b) == x)
            {
                cout<<a<<" "<<b<<endl;
                return;
            }
        }
    }
}

int main()
{
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 6220
#include<bits/stdc++.h>
#define M 1500005
using namespace std;
int n,ans=0; char c[M]={0};
int a[M+1]={0},cnt=0;
int main(){
	scanf("%s",c+1); n=strlen(c+1);
	for(int i=1;i<=n;i++) a[M-i+1]=c[n-i+1]-'0';
	for(int i=M,g=0;i;i--){
		int s=a[i]*9+g;
		a[i]=s%10; g=s/10;
	}
	for(int i=M;i;i--) cnt+=a[i];
	for(int k=1;;k++){
		for(int i=M,g=9;g;i--){
			int s=a[i]+g;
			cnt-=a[i];
			a[i]=s%10; g=s/10;
			cnt+=a[i];
		}
		if(k*9>=cnt) {printf("%d\n",k); return 0;}
	}
}

Measured memory_bytes: 6656
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <iostream>
using namespace std;
int main()
{
	long long int a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b, c) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    DRIII(a,b,c);
    DRII(d,e);
    LL an=0;
    if(a&&d&&e)an=3LL+(a-1)/2*2+(d-1)/2*2+(e-1)/2*2;
    an=max(an,a/2*2LL+d/2*2LL+e/2*2LL);
    cout<<an+b<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile("\\s");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 171144
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int sum[100000] = {};
	for (int i = 1; i <= n / 2; i++) {
		sum[i] += i % 10 + i % 100 / 10 + i % 1000 / 100 + i % 10000 / 1000 + i % 100000 / 10000 ;
		int j = n-i;
		sum[i] += j % 10 + j % 100 /10 + j % 1000 / 100 + j % 10000 / 1000 + j % 100000 / 10000 ;
	}
	int ans=1000;
	for (int i = 1; i <= n / 2; i++) {
		if (ans > sum[i])ans = sum[i];
	}
	cout << ans << endl;
}

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

# In[21]:


import itertools

def main():
	N, K = [int(n) for n in input().split(" ")]
	D = [1] * 10
	for d in input().split(" "):
		D[int(d)] = 0
	L = [str(i) for i, v in enumerate(D) if v == 1]

	digit = len(str(N))
	cand = []
	for n in list(itertools.product(L, repeat=digit)):
		p = int("".join(list(n)))
		if p >= N:
			cand.append(p)
	if len(cand):
		print(min(cand))
	else:
		if L[0] == "0":
			print(str(L[1]) + "0" * digit)
		else:
			print(str(L[0]) * (digit + 1))


main()


# In[ ]:






Measured memory_bytes: 9460
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def ruiseki(mydata):
    res = [0]*(len(mydata)+1)
    for i in range(len(mydata)):
        res[i+1] = res[i] + mydata[i]
    return res

n, k , m = MI()
a = ruiseki(LI())
b = ruiseki(LI())
a = a
b = b

result = 0
index = k
for i, ii in enumerate(a):
    if ii > m:
        break
    while b[index] + ii > m:
        index -= 1
    result = max(result, i+index)
print(result)

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    StringBuffer buf = new StringBuffer();
    buf.append(str[0]);
    buf.append(str[1]);
    buf.append(str[2]);
    System.out.println(Integer.parseInt(buf.toString())%4==0?"YES":"NO");
  }
}

Measured memory_bytes: 32556
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
#include <bitset>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define ld long double
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rf(x) scnaf("%lf",&x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define sz(x) ((int) x.size())
#define ld long double

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

//mt19937 myrand(time(0));
//int get_rand(int n){return myrand()%n + 1;}
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5;

int n,a[N+10];

int main(){
    //Open();
    //Close();
    while(~ri(n)){
        ms(a,0);
        rep1(i,1,n) {
            int x;
            ri(x);
            a[x]++;
        }
        int ans = 0;
        rep1(i,0,N){
            int temp = a[i];
            if (i>0) temp+=a[i-1];
            if (i<N) temp+=a[i+1];
            ans = max(ans,temp);
        }
        oi(ans);puts("");
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int m = s1.length();
        int n = s2.length();
        int[][] dp = new int[m + 1][n + 1];

        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= n; j++) {
                if (i == 0 || j == 0) {
                    dp[i][j] = 0;
                } else {
                    char x = s1.charAt(i - 1);
                    char y = s2.charAt(j - 1);

                    if (x == y) {
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                    } else {
                        dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
                    }
                }
            }
        }

        String result = "";

        int i = m;
        int j = n;
        while (i >= 1 && j >= 1) {
            char x = s1.charAt(i - 1);
            char y = s2.charAt(j - 1);
            if (x == y) {
                result = s1.charAt(i - 1) + result;
                i--;
                j--;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    i--;
                } else {
                    j--;
                }
            }
        }
        System.out.println(result);
        sc.close();
    }
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if ((A>=1) && (A<=9)) {
        if ((B>=1) && (B<=9)) {
            cout << A * B << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


if len(set(LI())) == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <stdio.h>
#define ll              long long
#define fr(i,j,p)       for(ll i=j; i<p ;i++)
#define frr(i,j,p)      for(int i=j; i>=p ;i--)
#define PI              3.14159265358979323846
#define print(m)        std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define mkp             make_pair
#define pb              push_back
#define M1              32
#define lbindex(a,x)    (int)(lower_bound(a.begin(), a.end(),x)-a.begin());
#define upindex(a,x)    (int)(upper_bound(a.begin(), a.end(),x)-a.begin());
#define all(a)          (a).begin(),(a).end()
#define mem(b,a,n)      memset(b,a,sizeof(b[0])*n);
#define meme(b,a,n,m)   memset(b,a,sizeof(b[0][0])*n*m);
#define ff              first
#define ss              second
#define endl            '\n'

using namespace std;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;

ll mdd=998244353;
ll md=1000000007;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t; cin>>s>>t;
    int ans=0;
    fr(i,0,s.length())
    {
        if(s[i]!=t[i])  ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3768
import java.util.Arrays;
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 c=sc.nextInt();
		int[] abc= {a,b,c};
		Arrays.sort(abc);
		System.out.println(abc[0]+" "+abc[1]+" "+abc[2]);
	}

}



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

int main() {
  int N ;
  cin >> N ;

  if ( N % 1000 != 0 ){
  cout << 1000 - (N % 1000) << endl;
  }
  else if ( N % 1000 == 0){
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		if(s.charAt(0) == s.charAt(2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

#define MAXN 100000
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;

map<int, int> mp;

// adj:= (vertex, distance)
vector<pair<int, int>> adj[MAXN];

void dijkstra(int r) {
    // adj:= (-distance, vertex)
    priority_queue<pair<int, int>> PQ;
    int color[MAXN];
    int d[MAXN];
    rep(i, n) {
        color[i] = WHITE;
        d[i] = INF;
    }
    
    d[r] = 0;
    PQ.push(make_pair(d[r], r));
    color[r] = GRAY;

    while(!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        if (d[u] < f.first * (-1)) continue;

        rep(i, adj[u].size()) {
            int v = adj[u][i].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][i].second) {
                d[v] = d[u] + adj[u][i].second;
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    rep(i, n) {
        if (d[i] == INF) continue;
        mp[d[i]]++;
    }
}

int main()
{   
    int x, y;
    cin >> n >> x >> y;
    --x, --y;

    rep(i, n) {
        
        adj[i].push_back(make_pair(i+1, 1));
        adj[i+1].push_back(make_pair(i, 1));
    }

    adj[x].push_back(make_pair(y, 1));
    adj[y].push_back(make_pair(x, 1));

    rep(i, n) {
        dijkstra(i);
    }

    REP(i, 1, n) {
        cout << mp[i] / 2 << endl;
    }



    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
int main()
{
    int r;
    cin>>r;
    cout<<2*PI*r*1.0<<endl;
    return 0;
}


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

string rotate(string str){
	char start;
	start = str[str.size()-1];
	for(int i=str.size()-1;i >= 1;i--){
		str[i] = str[i - 1];
	}
	str[0] = start;
	return str;
}

int main(){
	string s,t,cmp;
	cin >> s;
	cin >> t;
	cmp = s;
	
	if(s != t){
		s = rotate(s);
		int cnt = 0;
		
		while(s != cmp && s != t){
			s = rotate(s);
			cnt++;
		}
		if(cnt != s.size()-1){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
author : seryu
title : ABC169C_"Multiplication3"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	ll a;
	long double b;
	cin >> a >> b;
	b *= 100;
	ll b_l = ll(round(b));
	ll ans = ll(a*b_l)/100;
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3796