akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i, k) for (auto &i : k)
#define all(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){

  int N,cnt=0;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  rep(i,N){
    for(int j=N-1;j>=i+1;j--){
      while(A[j]<A[j-1]){
        swap(A[j],A[j-1]);
        cnt++;
      }
    }
  }
  rep(i,N) {
    if( i ) cout << ' ';
    cout << A[i];
  } cout << endl;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1160
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

vector<ll> facts, invfacts;

ll extended_gcd(ll a, ll b, ll &x, ll &y) {
    if(a==0) {
        x = 0;
        y = 1;
        return b;
    }

    ll x1, y1;
    ll g = extended_gcd(b%a, a, x1, y1);

    x = y1-(b/a)*x1;
    y = x1;
    return g;
}

ll nck(ll n, ll k) {
    if(k>n)
        return 0;
    //return (facts[n]*invfacts[k]%N*invfacts[n-k]%N+N)%N;
    return (((((facts[n]*invfacts[k])%N)*invfacts[n-k])%N)+N)%N;
}

void initialize_facts(ll n, ll mod) {
    facts.resize(n+1);
    invfacts.resize(n+1);
    facts[0] = 1;
    invfacts[0] = 1;

    for(ll i=1;i<=n;i++) {
        facts[i] = (facts[i-1]*i)%N;
        ll x,y;
        extended_gcd(facts[i],mod,x,y);
        invfacts[i] = x;
    }
}


int main() {

    initialize_facts(2*Nmax+5,N);

    get3(h,w,n);
    vector<pll> A(n);
    rep(i,n) {
        get2(a,b);
        A[i] = {a,b};
    }

    sort(ALL(A));

    vector<ll> res(n,0);
    for(ll i=0;i<n;i++) {
        res[i] = nck(A[i].fi+A[i].se-2, A[i].fi-1);
    }

    ll ans = 0;

    for(ll i=0;i<n;i++) {
        ll val = res[i];

        for(ll j=i+1;j<n;j++) {
            ll m1 = A[j].fi-A[i].fi, n1 = A[j].se-A[i].se;
            if(m1>=0 && n1>=0)
                res[j] = ((res[j]-val*nck(m1+n1, n1))%N+N)%N;
        }

        ans = (ans + val*nck(h-A[i].fi+w-A[i].se,w-A[i].se))%N;
        // cout<<ans<<endl;
    }

    // rep(i,n)
    // printf("%lld-%lld = %lld\n", A[i].fi, A[i].se, res[i]);

    printf("%lld\n", ((nck(h+w-2,h-1) - ans)%N+N)%N);

    return 0;  
}

Measured memory_bytes: 3456
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char** argv)
{
  int N;
  std::cin >> N;
  std::vector<double> values;
  for (int i = 0; i < N; ++i) {
    double V;
    std::cin >> V;
    values.push_back(V);
  }

  std::sort(std::begin(values), std::end(values));

  double x = values[0];
  for (int i = 1; i < N; ++i) {
    double y = values[i];
    x = (x + y) / 2;
  }

  std::cout << x << std::endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int N;
vector<int> A, B;

void input(void) {
	cin >> N;
	A.resize(N);
	for (auto& ai : A) cin >> ai;
	B.resize(N);
	for (auto& bi : B) cin >> bi;
}

bool possible;
vector<int> res;

void solve(void) {
	map<int, int> cnt;
	for (auto ai : A) ++cnt[ai];
	for (auto bi : B) ++cnt[bi];
	possible = true;
	for (auto& e : cnt)
		possible &= e.second <= N;
	if (!possible) return;

	res.resize(N);
	for (int i = 0; i < N; ++i)
		res[i] = B[i];
	int idx;
	for (int i = 0; i < N; ++i) {
		if (i == 0 || A[i - 1] != A[i]) 
			idx = 0;
		if (A[i] != res[i]) continue;
		for (; idx < N; ++idx) {
			if (A[i] != res[idx] && A[idx] != res[i]) {
				swap(res[i], res[idx]);
				break;
			}
		}
	}
	for (int i = 0; i < N; ++i)
		possible &= A[i] != res[i];
}

int main(void) {
	input();
	solve();
	if (possible) {
		cout << "Yes" << endl;
		for (auto resi : res)
			cout << resi << " ";
		cout << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  long long a[100000];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  int x = a[0];
  for (int i = 1; i < N; i++) {
    x ^= a[i];
  }
  if (x == 0) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    
    ll x = x2;
    ll y = y2;
    ll dx = x2 - x1;
    ll dy = y2 -y1;
    
    for(ll i = 0; i<2; i++){
        swap(dx,dy);
        dx = -dx;
        x += dx;
        y += dy;
        cout<<x<<" "<<y<<endl;;
    }
    return 0;
}

    
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define r0 return 0
using namespace std;

int main()
{
    ll n,m,i,j,k,t,x;

    cin>>n>>k;

    ll a[n+5];


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

        cin>>a[i];
    }
    j=1;
    x=a[0];

    for(i=k;i<n;i++){

        if(a[i]>x){

            cout<<"Yes"<<endl;
        }
        else {

            cout<<"No"<<endl;
        }

        x=a[j];
        j++;
    }

    return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define INF 1000000000
#define MOD 1000000007
#define MAXN 100005
#define lint long long
using namespace std;

struct ii {
	int a, b;
	bool operator < (ii o) const {
		return tie(a, b) < tie(o.a, o.b);
	}
};

int TC, N, M, K, Q, x, y, z, cnt, mnm, mks, ptr, ans;

int mod(lint n) { return (n%MOD + MOD)%MOD; }

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	ios::sync_with_stdio(0);
	
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	for (int i = 0; i < c-a; i++) cout<<'R';
	for (int i = 0; i < d-b; i++) cout<<'U';
	for (int i = 0; i < c-a; i++) cout<<'L';
	for (int i = 0; i < d-b; i++) cout<<'D';
	cout<<'D';
	for (int i = 0; i <= c-a; i++) cout<<'R';
	for (int i = 0; i <= d-b; i++) cout<<'U';
	cout<<'L';
	cout<<'U';
	for (int i = 0; i <= c-a; i++) cout<<'L';
	for (int i = 0; i <= d-b; i++) cout<<'D';
	cout<<"R\n";
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
  //static Action yes = Yes;
  //static Action no = No;
  public struct arch{
    public long a;
    public long b;
    public arch(long _a, long _b){
      a = _a;
      b = _b;
    }
  }

  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ').Select(long.Parse);
    var N = temp.ElementAt(0);
    var M = temp.ElementAt(1);
    var archList = new List<arch>();
    var ans = (long)0;
    var breakArch = (long)0;
    for(var i = 0; i < M; i++){
      var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
      archList.Add(new arch(temp2.ElementAt(0), temp2.ElementAt(1)));
    }
    archList = archList.OrderBy(x => x.b).ToList();

    archList.ForEach(x => {
      if(ans == 0 || breakArch < x.a){
        breakArch = x.b - 1;
        ans++;
      }

    });
    
    Console.WriteLine(ans);

  }
  
}

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

namespace AtCoder
{
    public class CodeABC138A
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            Console.WriteLine(funcMain(s1,s2));

            Console.ReadKey();
        }

        static public string funcMain(string arg1, string arg2)
        {
            var N = int.Parse(arg1);
            var Color = arg2;

            return N < 3200 ? "red" : Color ;
        }
    }
}


Measured memory_bytes: 11092
s = input()
import re
import math
ans = [0]*len(s)
a = [i.start() for i in re.finditer("RL",s)]

l_side = 0
r_side = 0
for i in range(len(a)-1):
    
    
    if s[a[i]+2:a[i+1]].find("R") != -1:
        r_side = a[i]+1 + s[a[i]+2:a[i+1]].find("R") 
        ans[a[i]+1] =math.ceil((a[i] - l_side)  / 2) + ((r_side - a[i]-1)//2) + 1
        ans[a[i]] = ((a[i] - l_side)  // 2) + math.ceil((r_side - a[i]-1)/2)+1
        
    else:
        r_side = a[i+1]-1
        ans[a[i]+1] = math.ceil((a[i] - l_side)  / 2) + ((r_side - a[i]-1)//2) + 1
        ans[a[i]] = ((a[i] - l_side)  // 2) + math.ceil((r_side - a[i]-1)/2)+1
    l_side = r_side+1
    
#最後に
ans[a[-1]+1] = math.ceil((a[-1] - l_side)  / 2) + ((len(s) - a[-1]-2)//2) + 1
ans[a[-1]] =   ((a[-1] - l_side)  // 2) + math.ceil((len(s) - a[-1]-2)/2)+1
L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Measured memory_bytes: 19912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
	int A, B; cin >> A >> B;
	int ans = 0;
	int b = 1;
	while (b < B) {
		b += A - 1;
		ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,i,j,k,sum=0;
	int a[100]={0};
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
			if(a[i]<a[j]){
				k=a[i];
				a[i]=a[j];
				a[j]=k;
			}
		}
	}
	for(i=0;i<N;i++){
		if(i%2==0){
			sum+=a[i];
		}else{
			sum-=a[i];
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() 
{
    long long int x,k,d;
    cin>>x>>k>>d;
    if(x<0)
    x*=-1;
    long long int temp=x/d,temp1;
    //cout<<temp<<endl;
    if(temp>=k)
    {
        cout<<abs(x-(k*d));
    }
    else
    {
        temp1=x-d*temp;
            if((k-temp)%2)
            {
                cout<<abs(temp1-d);
            }
            else
            {
                cout<<abs(temp1);
            }
    }
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int n;
    cin >>n;
    string s;
    cin >> s;

    int hidari=0;
    int migi=0;
    int i;
    int cnt=0;
    for( i=0; i<n;i++){
        if(s[i] == '('){
            hidari+=1;
        }
        else{
            migi +=1;
            if(migi > hidari){
                cnt+=1;
                migi=0;
                hidari=0;
            }
        }
    }
    REP(i,cnt){
        s.insert(s.begin(),'(');
    }
    REP(i,hidari - migi) s.insert(s.end(),')');
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;

  return 0;
}


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

# define C continue;

# define ll long long
# define ld long double

# define pb push_back
# define I insert
# define PQ priority_queue

# define vi vector < int >
# define vll vector < ll >
# define vc vector < char >
# define vb vector < bool >
# define vs vector < string >

# define vvi vector < vector < int > >
# define vvll vector < vector < ll > >
# define vvc vector < vector < char > >
# define vvb vector < vector < bool > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >

# define vpii vector < pair < int , int > >
# define vpll vector < pll >

# define F first
# define S second

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    int x ;
    cin >> x ;

    int max_n = x ;

    for ( int lo = 1 , hi = 5000 ; lo <= hi ; )
    {
        int mid = lo + hi >> 1 ;
        int temp = (mid * ( mid + 1 )) >> 1 ;

        if ( ((mid * ( mid + 1 )) >> 1) >= x )
            max_n = mid , hi = mid - 1 ;

        else lo = mid + 1 ;
    }

    int place = max_n ;

    while ( x > 0 )
    {
        int p = min ( place , x ) ;

        x -= p ;
        cout << p ; line ;

        place = p - 1 ;
    }
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3608
import scala.io.StdIn.readLine

object Main extends App {
	val Array(n, k) = readLine().split(" ").map(_.toLong)

	def min0(x:Long) = if (x<0) 0 else x

	println((1.toLong to n).view.map(b => if (k < b) (n/b)*(b-k)+min0(n%b+1-k)-(if(k==0)1 else 0) else 0).sum)
}

Measured memory_bytes: 37764
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
bc = []
for _ in range(m):
  b,c = map(int,input().split())
  bc.append([b,c])
bc.sort(key=lambda x: x[1],reverse=True)
i = 0
j = 0
TF = True
while j < m and TF:
  x = bc[j][0]
  y = bc[j][1]
  k = 1
  while k <= x and TF:
    if a[i] < y:
      a[i] = y
      if i < n-1:
        i += 1
        k += 1
      else:
        TF = False
    else:
      TF = False
  j += 1
print(sum(a))

Measured memory_bytes: 25548
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define endl "\n"
#define oo 0x3f3f3f3f3f3f3f3fLL
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define setdp memset(dp,-1,sizeof(dp))
#define db(x) cout<<" LOOK "<<(#x)<<" = "<<x <<'\n'
#define NumofDigits(n)   ((long long)log10(n)+1)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};*/
inline void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //File();
    string s;
    cin>>s;
    int cnt=0;
    for(int i=1; i<sz(s); i++)
    {
        if(s[i] == s[i-1] and s[i] == '1')
            cnt++,s[i]='0';
        else if(s[i] == s[i-1] and s[i] == '0')
            cnt++,s[i]='1';
    }
    cout<<cnt;
}


Measured memory_bytes: 3724
#include <iostream>

int main(){
   int N;
   int T, H, A;
   std::cin >> N >> T >> A;
   int index = 0;
   int min = 1000000;
   for(int i=0; i<N; ++i){
      std::cin >> H;
      int t = T*1000 - H * 6;
      if(min>abs(t-A*1000)){
	 min = abs(t-A*1000);
	 index = i + 1;
      }
   }
   std::cout << index << std::endl;

   return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	int i;
	int a[110];
	bool flag = false;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2 != 0) continue;
		if (a % 3 != 0 && a % 5 != 0) flag++;
	}
	if (flag) cout << "DENIED";
	else cout << "APPROVED";
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
    int n;    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N, X; 
	cin >> N >> X; 
	if(X == 1 || X == N * 2 - 1) cout << "No" << endl; 
	else{
		cout << "Yes" << endl; 
		vector<int> A; 
		for(int i = 1; i < X - 1; i++){
			A.push_back(i); 
		}
		for(int i = X + 2; i < N * 2; i++){
			A.push_back(i); 
		}
		A.insert(A.begin() + N-2, X+1); 
		A.insert(A.begin() + N-2, X); 
		A.insert(A.begin() + N-2, X-1); 
		for(int i = 0; i < A.size(); i++){
			cout << A.at(i) << endl; 
        	}
	}	
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  for ( int h = 1; ; ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- )
    insertionSort(A, n, G[i]);
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  printf("%d\n", G.size());
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 6680
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int sum(int n);

int main()
{
	int ans = (1 << 30);
	int a, b;
	int n;

	scanf("%d", &n);

	for (a = 1; a < n; a++) {
		b = n - a;

		ans = min(ans, sum(a) + sum(b));
	}

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

	return 0;
}

int sum(int n)
{
	int res =0;

	while (n) {
		res = res + n % 10;

		n = n / 10;
	}

	return res;
}


Measured memory_bytes: 128
N=io.read"*n"
io.read()
S=io.read()
local function count_char(s,c)
	local ret=0
	for _ in s:gmatch(c)do ret=ret+1 end
	return ret
end
c=count_char(S,"R")*count_char(S,"G")*count_char(S,"B")
for i=1,N do
	local I=S:sub(i,i)
	for d=1,(N-i)/2 do
		local J=S:sub(i+d,i+d)
		local K=S:sub(i+d+d,i+d+d)
		if(I~=J and J~=K and K~=I)then c=c-1 end
	end
end
print(c)

Measured memory_bytes: 2748
#include <iostream>
using namespace std;
string lower(string str);

main(){
	int count=0;
	string W,T;
	cin>>W;
	W=lower(W);
	while(cin>>T&&T!="END_OF_TEXT"){
		int index=0;
		if(W==lower(T)){
			count++;
		}
	}
	cout<<count<<endl;
}

string lower(string str){
	int length=str.length();
	for(int i=0;i<length;i++){
		if('A'<=str[i]&&str[i]<='Z'){
			str[i]+=0x20;
		}
	}
	return str;
}

Measured memory_bytes: 1196
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn solve(aa: &Vec<i64>) -> Option<(i64, i64)> {
  let mut l = 2;
  let mut r = 2;
  for &a in aa.iter().rev() {
    let next_l = (l + a - 1) / a * a;
    let next_r = r / a * a + a - 1;
    if next_l > next_r {
      return None;
    }
    l = next_l;
    r = next_r;
  }
  Some((l, r))
}

fn main() {
  input! {
    k: usize,
    aa: [i64; k],
  }
  match solve(&aa) {
    Some((l,r)) => println!("{} {}", l, r),
    None => println!("-1"),
  }
}


Measured memory_bytes: 6524
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> a(3);
    for (int i = 0; i < 3; i++) { cin >> a[i]; }
    sort(a.begin(), a.end(), greater<int>());
    int ans = 0;
    int d1 = a[0] - a[1];
    ans += d1;
    int d2 = a[0] - a[2] - (a[0] - a[1]);
    ans += d2 / 2 + (d2 % 2) * 2;
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fore(a,b,c) for(int a=b; a < c; a++)

typedef long long ll;
using namespace std;
const int N = 2e5+5;
const int M = 1e9+7;

ll n, dp[N][2][2];
vector<int> g[N];

ll dfs(int node, bool white, bool blackparent, int parent) {
    ll &r = dp[node][white][blackparent];
    if (r != -1) return r;
    r = 1;
    for(auto v : g[node]) {
        if (v != parent) {
            if (white) {
                r = (r*(dfs(v, true, white, node)%M + dfs(v, false, white, node)%M)%M)%M;
            } else {
                r = (r*(dfs(v, true, white, node))%M)%M;
            }
        }
    }
    return r%M;
}

int main() {

    cin >> n;
    fore(i,0,n-1) { 
        int u, v;
        cin >> u >> v;u--, v--;
        g[u].push_back(v);     
        g[v].push_back(u);     
    }
    fore(i,0,n) {
        dp[i][0][0] = -1;
        dp[i][0][1] = -1;
        dp[i][1][0] = -1;
        dp[i][1][1] = -1;
    }
    ll res = (dfs(0, 0, 0, -1)%M + dfs(0, 1, 0, -1)%M)%M;
    cout << res << endl;
}

Measured memory_bytes: 19840
#行列のインプットdata挿入
list_xy = list(map(int, input().split()))

#初期リストの作成
list_A = [[0 for i in range(list_xy[1])] for j in range(list_xy[0])]
list_b = list()
result = list()
#print(list_A)
#print(list_b)

#リストへインプットdata挿入
for i in range(list_xy[0]):
    input_temp = list(map(int, input().split()))
    for j in range(list_xy[1]):
        list_A[i][j] = input_temp[j]
#print(list_A)

for i in range(list_xy[1]):
    list_b.append(int(input()))
#print(list_b)

#計算実施
for i in range(list_xy[0]):
    result_temp = 0
    for j in range(list_xy[1]):
        result_temp += list_A[i][j] * list_b[j]
    result.append(result_temp)
#print(result)

#計算結果の表示
for i in range(len(result)):
    print(result[i])



Measured memory_bytes: 5796
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場


//main
int main() {
	input();
	string s;
	cin >> s;
	int n = s.size();
	ff(i, 0, (n - 1) / 2) {
      //cout<<s[i]<<" "<<s[n - 1 - i]<<endl;
		if (s[i] != s[n - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	string a;
	ff(i, 0, (n - 1) / 2) {
		a += s[i];
	}
 // cout<<a<<endl;
	ff(i, 0, (a.size()) / 2) {
      //cout<<a[i]<<" "<<a[a.size() - 1 - i]<<endl;
		if (a[i] != a[a.size() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
    long long A, B, C; cin >> A >> B >> C;
    if (A % 2 || B % 2 || C % 2) {
        cout << 0 << endl;
        return 0;
    }
    if (A == B && B == C) { 
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        long long nowA = A, nowB = B, nowC = C;
        A = (nowB + nowC) / 2;
        B = (nowC + nowA) / 2;
        C = (nowA + nowB) / 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def sum_of_digits(n)
        r = 0
        while n > 0
            r += n % 10
            n /= 10
        end
        return r
    end
     
    num = gets.to_i
     
    sum = sum_of_digits(num)

    puts (num % sum == 0 ? 'Yes' : 'No')

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

int main(){
  int n; cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    v.push_back(k);
  }
  int mi = 1e9;
  for (int u = -100; u <= 100; u++) {
    int m = 0;
    for (int i = 0; i < n; i++) {
      m += (v[i] - u) * (v[i] - u);
    }
    mi = min(m, mi);
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003;
int n, a[N];
LL ans;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%d", a + i), a[i] -= i;
	sort(a + 1, a + n + 1);
	int b = a[n + 1 >> 1];
	for(Rint i = 1;i <= n;i ++) ans += abs(a[i] - b);
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#define N 100005
using namespace std;

int n, cnt, s, a[N], num[N];
int v[N];
bool c[N];
queue<int> q, q2;
vector<int> b[N];
int f(int p) {
    int i, t, mx = 0, g = 0, z;
    vector<int> d;
    if (b[p].size() == 0) return 0;
    d.clear();
    for (i = 0; i < b[p].size(); i++) {
        z = b[p][i];
        t = f(z) + 1;
        d.push_back(t);
    }
    sort(d.begin(), d.end());
    for (i = 0; i < d.size(); i++) {
        if (d[i] <= g) g++;
        else g = d[i];
    }
    return g;
}

int main()
{
    int i, j, t, t2;
//    freopen ("input.txt", "r", stdin);
    cin >> n;
    for (i = 2; i <= n; i++) {
        scanf ("%d", &a[i]);
        c[a[i]] = true;
        b[a[i]].push_back(i);
    }
    cout << f(1);
/*    q.push(1);
    s = 1;
    while (!q.empty()) {
        t = q.front(); q.pop();
        if (b[t].size() == 0) continue;
        s += b[t].size()-1;
        for (i = 0; i < b[t].size(); i++) {
            q.push(b[t][i]);
        }
    }
//    while (cnt < n) {
//        k++;
    a[1] = 0;
    for (i = 2; i <= n; i++) {
        if (!c[i]) {
            q.push(i);
            q2.push(1);
        }
    }

    while (!q.empty()) {
        t = q.front(); q.pop();
        t2 = q2.front(); q2.pop();
        if (t == 1) {
            cnt++;
            if (cnt == s) break;
        } else {
            if (v[a[t]] == t2) {
                q.push(t);
                q2.push(t2 + 1);
            } else {
                v[a[t]] = t2;
                q.push(a[t]);
                q2.push(t2 + 1);
            }
        }
    }
//    }
*/
//cout << t2 - 1 << endl;
    return 0;
}


Measured memory_bytes: 13952
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int[] nums = new int[n], dp = new int[n];
		for (int i = 0; i < n; i++) {
			nums[i] = in.nextInt();
		}
		dp[1] = Math.abs(nums[0] - nums[1]);
		for (int i = 2; i < n; i++) {
			dp[i] = Integer.MAX_VALUE;
			for (int j = 1; j <= k; j++) {
				if(i - j >= 0){
					dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(nums[i] - nums[i-j]));
				}
			}
		}
		System.out.println(dp[n - 1]);
	}
}

Measured memory_bytes: 61536
#include<iostream>
using namespace std;
int h,w;
char s[50][50];
bool check(int i, int j){
    if(s[i][j] == '.')return true;
    if(i-1>=0 && s[i-1][j] == '#')return true;
    if(j+1<w && s[i][j+1] == '#')return true;
    if(i+1<h && s[i+1][j] == '#')return true;
    if(j-1>=0 && s[i][j-1] == '#')return true;
    return false;
}
int main(void){
    cin>>h>>w;
    for(int i(0);i<h;i++){
        for(int j(0);j<w;j++){
            cin>>s[i][j];
        }
    }
    bool flag(true);
    for(int i(0);i<h;i++){
        for(int j(0);j<w;j++){
            if(!check(i,j))flag = false;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
  long long k, a, b;
  cin>>k>>a>>b;
  if (b - a <= 1) {
    cout<<k + 1<<endl;
    return 0;
  }
  if (a >= k) {
    cout<<k + 1<<endl;
    return 0;
  }
  int cnt = 0;
  long long n = 1;

  while (cnt < k) {
    if (n < a) {
      ++n;
      ++cnt;
    } else {
      if (cnt <= k - 2) {
        n += b - a;
        cnt += 2;
      } else {
        ++n;
        break;
      }
    }
  }
  cout<<n<<endl;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> X(N);
  for (ll i = 0; i < N; i++) cin >> X.at(i);
  vector<ll> Y(X);
  sort(Y.begin(), Y.end());
  ll lo = Y[N/2 - 1];
  ll hi = Y[N/2];
  for (ll i = 0; i < N; i++) {
    ll a = (X[i] <= lo) ? hi : lo;
    cout << a << "\n";
  }

  return 0;
}



Measured memory_bytes: 6356
import sys
N, M = map(int, input().split())
route = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    route[a-1].append(b)
    
for i in route[0]:
    if len(route) != 1:
        for j in route[i-1]:
            if j == N:
                print('POSSIBLE')
                sys.exit()
    else:
        if i == N:
            print('POSSIBLE')
            sys.exit()
                
print('IMPOSSIBLE')


Measured memory_bytes: 33544
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line;
		StringTokenizer token1;
		
	
		while ((line = input.readLine()) != null && !line.isEmpty()) {
			int n=Integer.parseInt(line);
			if(n==0) break;
			int a=0, b=0;
			int sum1=0, sum2=0;
			for(int i=0;i<n;i++){
				line=input.readLine();
				token1 = new StringTokenizer(line);
				a=Integer.parseInt(token1.nextToken());
				b=Integer.parseInt(token1.nextToken());
				if(a>b) sum1+=a+b;
				if(a<b) sum2+=a+b;
				if(a==b) sum1+=a;
				if(a==b) sum2+=b;
			
			}
			System.out.println(sum1+" "+sum2);
		}
	}
}	

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

int main(int argc, const char * argv[]) {
    long long int x,y;
    cin >> x >> y;
    long long int ans =0;
    if(x<y && x >=0 && y>=0){
        ans = y-x;
    }else if(x>y && x >= 0 && y > 0){
        ans = abs(x)-abs(y) + 2;
    } else if(x>y && x >= 0 && y == 0){
        ans = abs(x)-abs(y) + 1;
    }else if(abs(x)>abs(y) && x<0 && y<0){
        ans = y-x;
    }else if(abs(x)<abs(y) && x<0 && y<0){
        ans = abs(y-x) + 2;
    }else if(abs(x)<abs(y) && x>=0 && y<0){
        ans = abs(y) - abs(x) + 1;
    }else if(x > y && x>=0 && y<0){
        ans = abs(x) - abs(y) + 1;
    }else if(abs(x)>abs(y) && x<0 && y>0){
        ans = abs(x) -abs(y) +1;
    }else if(x<y && x<0 && y>0){
        ans = abs(y) - abs(x) + 1;
    }else if(x<y && x<0 && y==0){
        ans = abs(x) - abs(0);
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N;
  IN(N);
  map<string, ll> mp;
  REP(n,N){
    string str;
    IN(str);
    sort(ALL(str));
    mp[str]++;
  }

  ll ans = 0;
  for(auto itr : mp){
    ans += ((itr.second-1)*itr.second)/2;
  }
  OUT(ans);

  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w, k;
string s[800];

int v[800][800];

int main() {
	cin >> h >> w >> k;
	inc(i, h) { cin >> s[i]; }
	
	int si, sj;
	inc(i, h) {
	inc(j, w) {
		v[i][j] = h * w + 1;
		if(s[i][j] == 'S') { si = i; sj = j; s[i][j] = '.'; }
	}
	}
	
	int di[4] = { 1, 0, -1,  0 };
	int dj[4] = { 0, 1,  0, -1 };
	
	v[si][sj] = 0;
	
	queue<pair<int, int>> q;
	q.emplace(si, sj);
	while(! q.empty()) {
		auto e = q.front(); q.pop();
		if(v[e.FI][e.SE] == k) { break; }
		
		inc(l, 4) {
			int ii = e.FI + di[l];
			int jj = e.SE + dj[l];
			if(inID(ii, 0, h) && inID(jj, 0, w) && s[ii][jj] == '.') { } else { continue; }
			
			if(setmin(v[ii][jj], v[e.FI][e.SE] + 1)) { q.emplace(ii, jj); }
		}
	}
	
	int ans = h * w + 1;
	inc(i, h) {
	inc(j, w) {
		if(v[i][j] <= k) {
			setmin(ans, (i + k - 1) / k);
			setmin(ans, (j + k - 1) / k);
			setmin(ans, (h - 1 - i + k - 1) / k);
			setmin(ans, (w - 1 - j + k - 1) / k);
		}
	}
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int A, B, C, D, E, F;

int dp[3001][3001]; // dp[x][y]: x in y

int main() {
    cin >> A >> B >> C >> D >> E >> F;

    for (int j = 0; j <= 3000; ++j) fill(dp[j], dp[j]+3000, 0);
    dp[0][0] = 1;

    int jj = 0, kk = 100*A;
    for (int j = 0; j <= F; ++j) {
        for (int k = j; k <= F; ++k) {
            if (j < k && dp[j][k] == 1 && j * 100 <= E * (k-j)) {
                // jj / kk < j / k
                if (jj * k < j * kk) {
                    jj = j; kk = k;
                }
            }

            if (dp[j][k] == 0) continue;
            if (k + 100*A <= F) {
                dp[j][k+100*A] = 1;
            }
            if (k + 100*B <= F) {
                dp[j][k+100*B] = 1;
            }

            if (k + C <= F) {
                dp[j+C][k+C] = 1;
            }
            if (k + D <= F) {
                dp[j+D][k+D] = 1;
            }
        }
    }

    cout << kk << " "<< jj << endl;
    return 0;
}


Measured memory_bytes: 36088
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>
#include<queue>
#include<deque>

using namespace std;

int main(){
	char s[20];
	bool bl=true;
	scanf("%s",s);
	for(int i=0;;i+=2){
		if(s[i]=='\0') break;
		if(s[i]=='h'&&s[i+1]=='i') bl=true;
		else bl=false;
	}
	
	if(bl)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;


int main(void){
  
  string S;
  int count = 0;
  cin >> S;

  int length = S.length();

  for(int i = 0; i < S.length()/2 ; i++){
    if(S[i] != S[S.length()-1-i]){
      count++;
    }
  }

  cout << count << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const double dINF = 1000000000000000000.0;

int main(){
	string str;
	cin >> str;
	char tmp=str[0];
	int ans = 0;
	for (auto &&c : str) {
		if (c != tmp)ans++;
		tmp = c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int x = a[n-1];
    int y = a[0];
    rep(i, n) if (abs(x/2 - a[i]) <= abs(x/2 - y) && x != a[i]) y = a[i];
    cout << x << " " << y << endl;
}


Measured memory_bytes: 640
import sys

n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
d = {}
for i in range(0, n):
    d[i+1] = A[i]

d = sorted(d.items(), key= lambda x:x[1])
#print(d)
ans = []
for z in d:
    ans.append(z[0])

print(*ans)

Measured memory_bytes: 25628
//https://beta.atcoder.jp/contests/abc110/tasks/abc110_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << max({ stoi( A ) + stoi( B + C ), stoi( A ) + stoi( C + B ),
                  stoi( B ) + stoi( A + C ), stoi( B ) + stoi( C + A ),
                  stoi( C ) + stoi( A + B ), stoi( C ) + stoi( B + A ) }) << endl;
    return 0;
}

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

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

arr=list(map(int,input().split()))

ans=[0]*N

ans[N-2]=abs(arr[-2]-arr[-1])

for i in range(N-3,-1,-1):
	minn=100000000000000
	for j in range(min(K,N-i-1)):
		minn = min(minn,abs(arr[i]-arr[i+j+1])+ans[i+j+1])
	ans[i]=minn

print(ans[0])

Measured memory_bytes: 52444
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}

int main()
{
    ios;
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++)
    {
        cin>>d[i];
    }
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;



}









Measured memory_bytes: 3664
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<Color> set = new TreeSet<>();
		for (int i = 0; i < n; i++) {
		    Color x = new Color(n - i, sc.nextInt());
		    Color target = set.lower(x);
		    if (target != null) {
		        set.remove(target);
		    }
		    set.add(x);
		}
		System.out.println(set.size());
	}
	
	static class Color implements Comparable<Color> {
	    int idx;
	    int value;
	    
	    public Color (int idx, int value) {
	        this.idx = idx;
	        this.value = value;
	    }
	    
	    public int hashCode() {
	        return idx;
	    }
	    
	    public int compareTo(Color another) {
	        if (value == another.value) {
	            return idx - another.idx;
	        } else {
	            return value - another.value;
	        }
	    }
	    
	    public boolean equals(Object o) {
	        Color another = (Color)o;
	        return idx == another.idx && value == another.value;
	    }
	}
}


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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int a, b;
	cin>>a>>b;
	for(int n = 1; n <= 10000; n++){
		int x = n*8/100;
		int y = n/10;
		if(x == a && y == b){
			cout<<n<<endl;
			exit(0);
		}
	}
	cout<<-1<<endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int a[305][305], dp[305][305];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) REP(j, n) cin >> a[i][j], dp[i][j] = a[i][j];

  REP(k, n) {
    // cout << "k:" << k << endl;
    // cout << "---------" << endl;
    // REP(i, n) {
    //   REP(j, n) {
    //     cout << dp[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    // cout << "----------" << endl;
    REP(i, n) REP(j, n) {
      if(k == i || k == j || i == j || dp[i][k] == INF || dp[k][j] == INF) continue;
      // cout << i << " " << j << " " << dp[i][k] << " " << dp[k][j] << " " << a[i][j] << endl;
      if(dp[i][k] + dp[k][j] == a[i][j]) {dp[i][j] = INF;}
      else if(dp[i][k] + dp[k][j] < a[i][j]) {cout << -1 << endl; return 0;}
    }
  }

  ll sum = 0;
  REP(i, n) {
    REP(j, n) {
      if(dp[i][j] != INF) sum += dp[i][j];
      // cout << dp[i][j] << " ";
    }
    // cout << endl;
  }
  cout << sum/2 << endl;

  return 0;
}


Measured memory_bytes: 1024