akhauriyash/Code-Regression huggingface dataset:
#include<string.h>
#include<stdio.h>
#include<stdlib.h>

int main(void) {
	char str[1001][33] = {0};
	int maxLength, maxL_index=0,count,maxFreq=0,maxF_index=0;
	int i,j,n=0;

	while (scanf("%s", &str[n]) != EOF) {
		n++;
	}

	maxLength = strlen(str[0]);
	for (j = 1; j<n; j++) {
		if (maxLength < strlen(str[j])) {
			maxLength = strlen(str[j]);
			maxL_index = j;
		}
	}
	
	for (i = 0; i<n; i++) {
		count = 1;
		for (j = i; j<n; j++) {
			if (strcmp(str[i],str[j]) == 0) {
				count++;
			}
		}
		if (maxFreq < count) {
			maxFreq = count;
			maxF_index = i;
		}
	}
	printf("%s %s\n", str[maxF_index], str[maxL_index]);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int b[n-1];
  for(int i=0;i<n-1;i++)cin>>b[i];
  int ret=b[0];
    for(int i=0;i<n-2;i++)ret+=min(b[i],b[i+1]);
    ret+=b[n-2];
  cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by mizuk on 2017/07/26.
 */
public class Main {
    private static int H;
    private static int W;
    private static int N;
    private static int a[];

    private static int table[][];

    public static void input(){
        Scanner scan = new Scanner(System.in);
        H = scan.nextInt();
        W = scan.nextInt();
        N = scan.nextInt();
        a = new int[N];

        for(int i=0;i<N;i++) {
            a[i] = scan.nextInt();
        }

        table = new int[H][W];
    }

    public static void main(String args[]){
        //入力
        input();

        int count_row = 0;  //行のカウント
        int count_col = 0;  //列のカウント
        int num = 1;
        boolean flag = true;

        int j = 0;
        while (j < N){
            // numの個数、a[j]回分だけ繰り返す
            for(int i=0;i<a[j];i++){
                if(count_row == H){
                    flag = !flag;
                    count_row--;
                    count_col++;
                }
                if(count_row == -1){
                    flag = !flag;
                    count_row++;
                    count_col++;
                }

                if(flag) table[count_row++][count_col] = num;   //flagがtrueのときはカウントアップ
                else table[count_row--][count_col] = num;       //flagがfalseのときはカウントダウン
            }
            num++;
            j++;
        }

        //出力
        for(int i=0;i<H;i++){
            for (int k=0;k<W;k++){
                System.out.print(table[i][k] + "  ");
            }
            System.out.println();
        }

    }
}

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

int main() {
	// your code goes here
	int n,x,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>x;
	    if(x%2==1 && i%2==1) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3620
N,K = map(int,input().split())
kisuu = 0
seisuu = 0
for i in range(1,N+1):
    if i%2==0:
        seisuu+=1
    else:
        kisuu+=1
if kisuu>=K or seisuu>=K:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;


int main(){
    long double L; cin >> L;
    long double L_div_3 = (long double)L/3;
    
    cout <<fixed<< L_div_3* L_div_3 * L_div_3 << setprecision(15) <<endl;
    

}


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

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c <<endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>             
ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}

ll none(ll i,ll j,ll n,ll m)
{
	if((i==0&&(j==0||j==m-1)) || (i==n-1&&(j==0||j==m-1))) return 2;
	else if(i==0 || j==0 || i==n-1 || j==m-1) return 3;
	else return 4;
}

// code beigns in main
int main()
{
	__Imperial_Lord__
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
    	ll read(n);
    	vl a(n);
    	cin >> a;
    	sort(all(a),greater<ll>());

    	// p1(a);
    	ll ans=a[0];
    	ll c=1,cnt=0;
    	rep(i,2,n)
    	{
    		// p1(a[c]);
    		if(cnt<2) ans+=a[c],cnt++;
    		if(cnt==2) cnt=0,c++;
    	}

    	p1(ans);
    }	
    exec;
}

Measured memory_bytes: 4780
#include <iostream>

using namespace std;

class Vector3{
public:
	double x,y;

	double operator*( Vector3 hoge ){
		return x * hoge.y - y * hoge.x;
	}

	void operator-=( Vector3 hoge ){
		x -= hoge.x;
		y -= hoge.y;
	}

};

int main(int argc, char const* argv[])
{
	Vector3 A,B,C,D;
	int n;

	cin >> n;

	for( int i = 0;i < n;i++ ){
		cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;

		B -= A;
		D -= C;

		double answer = B * D;

		if( answer == 0 ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}


	return 0;
}

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

bool overlap(int a, int b, int c, int d){
  assert( a < b ); assert( c < d );
  int aa = 0;
  for ( int i = 0; i < 10000; i++ ) aa += i;
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}

bool notOverlap(int a, int b, int c, int d){
  return b <= c || d <=a;
}

main(){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    } else {
      assert(notOverlap(a, b, s, f));
    }
  }
  cout << 0 << endl;
  return 0;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll Prev[2019], Next[2019];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    Prev[0] = 1;
    ll ans = 0;
    ll now = 0;
    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < 2019; j++) Next[j] = 0;
        now *= 10;
        now += (int)(S[i] - '0');
        now %= 2019;
        for(int j = 0; j < 2019; j++) {
            Next[j*10%2019] += Prev[j];
        }
        ans += Next[now];
        Next[now]++;
        swap(Prev, Next);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3772
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;

    int h[100010];

    rep(i,n){
        cin >> h[i];
    }

    if(n == 1){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = n-1;i >= 1;i--){
        if(h[i-1] > h[i]){
            h[i-1]--;
            if(h[i-1] > h[i]){
                cout << "No" << endl;
                return 0; 
            }
        } 
    }
    cout << "Yes" << endl;



    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b


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

int main() {
  int n, m;
  cin >> n >> m;
  int ab[100][2] = {0}, cd[100][2] = {0};
  for (int i = 0; i < n; i++) {
    cin >> ab[i][0] >> ab[i][1];
  }
  for (int i = 0; i < m; i++) {
    cin >> cd[i][0] >> cd[i][1];
  }

  int res[100] = {0};
  for (int i = 0; i < n; i++) {
    long long ans = abs(ab[i][0] - cd[0][0]) + abs(ab[i][1] - cd[0][1]);
    int ansid = 1;
    for (int j = 0; j < m; j++) {
      long long tmp = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]);
      if (ans > tmp) {
        ans = tmp;
        ansid = j + 1;
      }
    }
    res[i] = ansid;
  }

  for (int i = 0; i < n; i++) {
    cout << res[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
/*
 * FileName:     A_fix_2
 * CreatedDate:  2020-05-16 23:43:44 +0900
 * LastModified: 2020-05-17 00:21:21 +0900
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    int n;
    scanf("%d",&n);
    int *h = malloc(n*sizeof(int));

    for(int i=0;i<n;i++){
        scanf("%d",h+i);
    }
    int dp[n];
    memset(dp,0,sizeof(dp));
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        int s1,s2;
        s1=abs(h[i]-h[i-2])+dp[i-2];
        s2=abs(h[i]-h[i-1])+dp[i-1];
        if(s1<s2){
            dp[i]=s1;
        }
        else{
            dp[i]=s2;
        }
//        printf("%d ",dp[i]);
    }
    printf("%d\n",dp[n-1]);
    return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	int n, ans = 0;
	scanf("%d", &n);
	vector<mp> a(n);
	rep(i, n){
		int t;
		scanf("%d", &t);
		a[i] = mp(t, i);
	}
	
	sort(a.begin(), a.end());
	
	rep(i, n) if(a[i].sec%2 != i%2) ans++;
	
	cout << ans/2 << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    int f[1000]={};
    Rep(i,1,1000){
        f[i]=f[i-1]+i;
    }
    Rep(i,1,1000){
        if(f[i]-f[i-1]==b-a){
            cout<<f[i-1]-a<<endl;
            return;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a;
	int b;

	cin >> a >> b;

	if (a > 9) {
		cout << -1;
	}
	else if (b > 9) {
		cout << -1;
	}
	else {
		cout << a * b;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  ll OOF = 2019;
  ll l, r; cin >> l >> r;
  if( r - l > OOF ) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = OOF*OOF;
  for(ll i=l; i<=r; i++) {
    for(ll j=l; j<i; j++) smin(ans, (i*j)%OOF);
  }

  cout << ans << nl;

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
# # Educational DP Contest D
# 方針：dp[i][w] := i番目の物の中から，重さwを超えない時の価値の最大値
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+10) for _ in range(N+1)]

for i in range(N):
    for w in range(W+1):
        if w >= wv[i][0]:       # 重さwv[i][0]を入れられるか
            dp[i+1][w] = max(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

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

int main() {
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n.at(i) == '1') n.at(i) = '9';
        else n.at(i) = '1';
    }
    cout << n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

int M[N][N];
int color[N],d[N],f[N],cnt,num;
void dfs_2(int);
void dfs_1();

/*main??¢??°*/
int main(){

  int u,v,d,i,j;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      M[i][j]=0;}}

  for(i=0;i<num;i++){
    scanf("%d %d",&u,&d);
    u--;
    for(j=0;j<d;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs_1();
  return 0;
}
void dfs_2(int u){
  int v;
  color[u]=GRAY;

  /*????????????*/
  d[u]=++cnt;
  for(v=0;v<num;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_2(v);
    }
  }
  color[u]=BLACK;
  /*????????????*/
  f[u]=++cnt;
}

void dfs_1(){
  int i;

  /*?????????*/
  for(i=0;i<num;i++){
    color[i]=WHITE;
  }
  cnt=0;

  for(i=0;i<num;i++){
    if(color[i]==WHITE)dfs_2(i);
  }

  /*??¨???*/
  for(i=0;i<num;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int n,k,a[100005];
bool dp[100005];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i>=a[j])dp[i]|=!dp[i-a[j]];
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
    return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k) cin >> l[i] >> r[i];
    vector<mint> dp(n+1);
    vector<mint> dpsum(n+1);
    dp[1] = 1;
    dpsum[1] = 1;
    for (int i =2; i <= n; i++) {
        rep(j, k) {
            int li = i -r[j];
            int ri = i -l[j];
            if (ri < 0) continue;
            li = max(li, 1);
            dp[i] += dpsum[ri]-dpsum[li-1]; // dp[li]~dp[ri]
        }
        dpsum[i] = dpsum[i-1]+dp[i]; 
    }
    cout << dp[n] << endl;

    return 0;    
}

Measured memory_bytes: 6428
#include<iostream>
#include<string>

using namespace std;
int main()
{
	int N,a[100]={},i,j,k,key;
	cin>>N;
	for(i=0;i<N;i++)
		cin>>a[i];
	for(k=0;k<N-1;k++)
		cout<<a[k]<<" ";
	cout<<a[N-1]<<endl;

	for(i=1;i<N;i++){
		key = a[i];
		j = i-1;
		while(j>=0&&a[j]>key){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
			
		for(k=0;k<N-1;k++)
			cout<<a[k]<<" ";
		cout<<a[N-1]<<endl;	
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],B[N],n,mn,m,mx,idx,z,y,x;
//pair<int,int> X[N];
bool f;
#define days second
#define money first
vector<int>V [N] ;
priority_queue<int> p;
int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;++i){
        scanf("%d %d",&x,&y);
        if(x<=m)
        V[x].push_back(-y);
    }
    long long sum=0;
    for(int i=1;i<=m;++i){
        for(auto k:V[i])
        p.push(-k);
        if(p.size()){
        sum+=p.top();
        p.pop();
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 5632
sx,sy,tx,ty = gets.chomp.split(" ").map(&:to_i)
dx = tx-sx
dy = ty-sy
puts "R"*dx+"U"*dy+"L"*dx+"D"*dy+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"

Measured memory_bytes: 1916
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    int N;
    cin >> N;
    int a[N+1];
    rep(i, N + 1) a[i] = 0;
    int f;
    for (int x = 1; x <= 100; x++){
        for (int y = 1; y <= 100; y++){
            for (int z = 1; z <= 100; z++){
                f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f <= N) a[f] += 1;
            }
        }
    }
    for (int i = 1; i <= N; i++) cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 3232
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		long X=nextLong();
		long K=nextLong();
		long D=nextLong();
		X=Math.abs(X);
		long key=X/D;
		if(Math.abs(X-(D*key))>Math.abs(X-(D*(key+1))))
			key++;
		if(K>=key){
			K-=key;
			X=Math.abs(X-(key*D));
			if(K%2==1)
				System.out.println(Math.abs(X-D));
			else
				System.out.println(X);
		}
		else
			System.out.println(Math.abs(X-(D*K)));
	}
	public static long lmod(long i, long j) {
	     return (i%j)<0?(i%j)+0+(j<0?-j:j):(i%j+0);
	 }
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32540
from sys import stdin

def main():
    N, M = map(int, input().split())
    PY = [tuple(map(int, input().split())) for _ in [0] * M]

    py = sorted(PY, key=lambda x: x[1])
    py.sort()
    num = dict()
    prev = -1
    for v in py:
        current = v[0]
        if prev != current:
            i = 1
        num[v] = i
        i += 1
        prev = current
    for v in PY:
        s = str(v[0]).zfill(6) + str(num[v]).zfill(6)
        print(s)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 29392
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007ll
long long f[60];
int c[60];
int main()
{
	string a,b;
	int N,i;
	
	cin>>N>>a>>b;
	for(i=0;i<N;i++)
	{
		if(a[i]==b[i])c[++c[0]]=1;
		else c[++c[0]]=2,i++;
	}
	if(c[1]==1)f[1]=3;
	else f[1]=6;
	for(i=2;i<=c[0];i++)
	{
		if(c[i]==1)
		{
			if(c[i-1]==1)f[i]=2*f[i-1]%mod;
			else f[i]=f[i-1];
		}
		else
		{
			if(c[i-1]==1)f[i]=2*f[i-1]%mod;
			else f[i]=f[i-1]*3%mod;
		}
	}
	printf("%lld",f[c[0]]);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  string winner;
  if(A==B){
    cout << "Draw" << endl;
  }else if(A==1){
    cout << "Alice" << endl;
  }else if(B==1){
    cout << "Bob" << endl;
  }else if(A<B){
    cout << "Bob" << endl;
  }else{
    cout << "Alice" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        int maxd = K  - A[A.length - 1] + A[0];

        for (int i = 0; i < (N - 1); i++) {
            maxd = Math.max(maxd, A[i + 1] - A[i]);
        }

        System.out.println(K-maxd);
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
    int n; cin >> n;
    int mx = 0;
    ll tot = 0;
    rep(i, n){
        int x; cin >> x;
        if(mx > x) tot += mx - x;
        else mx = x;
    }
    cout << tot << endl;
    return;
}

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

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

class myqueue {
	using val_t = pair<string, int>;
	static constexpr int N = 100000;
	vector<val_t> m_data;
	int m_head;
	int m_tail;
public:
	myqueue():
		m_data(N),
		m_head(0),
		m_tail(0)
	{}

	void enqueue( const val_t& v ) {
		m_data.at( m_tail ) = v;
		m_tail = (m_tail + 1) % N;
	}

	val_t dequeue() {
		int pos = m_head;
		m_head = (m_head + 1) % N;
		return m_data.at( pos );
	}

	bool empty() const {
		return m_head == m_tail;
	}
};

int main() {
	int n, q;
	cin >> n >> q;

	myqueue pq;
	for( int i = 0; i < n; ++i ) {
		pair<string, int> p;
		cin >> p.first >> p.second;
		pq.enqueue( p );
	}

	int time = 0;

	while( !pq.empty() ) {
		auto p = pq.dequeue();

		if( p.second <= q ) {
			time += p.second;
			cout << p.first << ' ' << time << endl;
		}
		else {
			time += q;
			p.second -= q;
			pq.enqueue( p );
		}
	}
}



Measured memory_bytes: 6836
# Hanafuda Shuffle

ans = []

while True:
    n, r = map(int, input().split())
    if n == 0 and r == 0:
        break

    deck = [i + 1 for i in range(n)]
    deck.reverse()
    for i in range(r):
        p, c = map(int, input().split())
        p -= 1
        deck = deck[p:p+c] + deck[:p] + deck[p+c:]
    ans.append(deck[0])

for i in ans:
    print(i)



Measured memory_bytes: 5636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    vector<int> packs(3);
    for (int i = 0; i < 3; ++i)
        cin >> packs[i];
    sort(packs.begin(), packs.end());
    if (packs[0] + packs[1] == packs[2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int A,B,C,X,Y,a[200000],ans;
    cin >> A >> B >> C >> X >> Y;
    for (int i=0; i<200000; ++i){
        a[i]=2*i*C+max((X-i),0)*A+max((Y-i),0)*B;
    }
    ans = a[0];
    for (int i=0; i<200000; ++i){
        if (ans>a[i]) ans=a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
path = [list(map(int, input().split())) for _ in range(M)]
huben = N*(N-1)/2
hubenlist = [0]*M
hubenlist[M-1] = huben
UF = UnionFind(N)
for i in range(M-1, 0, -1):
    a, b = path[i]
    if not UF.same(a-1, b-1):
        hubenlist[i-1] = hubenlist[i] - (UF.size(a-1)*UF.size(b-1))
    else:
        hubenlist[i-1] = hubenlist[i]
    UF.union(a-1, b-1)
for i in range(M):
    print(int(hubenlist[i]))

            
            


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


int main() {
    int M;
    ll K;
    //llであることに注意
    cin >> M >> K;

    string ans;

    if(M==1){
        if(K==0){
            ans = "0 0 1 1";
        }else{
            ans = "-1";
        }
            cout << ans << endl;
        return 0;
    }


    if(0<=K&&K<(1<<M)){
        for(ll i=0;i<(1<<M);i++){
            if(i==K)continue;
            cout << i << " ";
        }
        cout << K << " ";

        for(ll i=(1<<M)-1LL;0<=i;i--){
            if(i==K)continue;
            cout << i << " ";
        }

        cout << K << endl;
        return 0;

    }else{
        ans = "-1";
    }

    cout << ans << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <functional>
#include <map>

using ll = long long;

int main()
{
	int N;
	static ll A[200000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}
	std::sort(A, A + N, std::greater<ll>());

	ll ans = 0;
	std::map<ll, int, std::greater<ll>> map;
	map.insert({A[0], 1});
	for (int i = 1; i < N; i++) {
		auto it = map.begin();
		ll key = it->first;
		ans += it->first;
		it->second--;
		if (it->second == 0) {
			map.erase(it);
		}
		it = map.find(A[i]);
		if (it != map.end()) {
			it->second += 2;
		}
		else {
			map.insert({A[i], 2});
		}

		//for (auto &e : map) {
		//	printf("%lld %d\n", e.first, e.second);
		//}
		//puts("----");
	}
	printf("%lld\n", ans);

	return 0;
}


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

int main() {
	long k,n,m=0;
	cin >> k >> n;
	long a[n],c[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			c[i] = k + a[0] - a[i];
		}
		else {
			c[i] = a[i + 1] - a[i];
		}
	}
	for (int i = 0; i < n; i++) {
		if (m < c[i]) {
			m = c[i];
		}
	}
	cout << k - m << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
  int n1,n2,l,t,i,x,a,b,ans;
int main()
{

  	cin>>x>>a>>b;
  	
	x=x-a;ans=0;
  	while (x>0)
  	  {
  	  	if (x>=b)
		{
		  x-=b;
		  
	    }
		else
	      break;
      }
      
    cout<<x;
}

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

#define N 200001

int main(void)
{
    string s, t;
    cin >> s;
    cin >> t;
    
    int cnt = 0;
    for (int i = 0; i < s.size() ; i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

typedef long long ll;
 
int main(){
  char x, y;
  cin >> x >> y;
  string ans;
  if(x>y) ans = ">";
  else if(x<y) ans = "<";
  else ans = "=";
  cout << ans << endl;
  return 0;
}


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

int main(void) {

    int a, b, c;
    cin >> a >> b >> c;
    vector<int> t(100+1, 0);
    t[a]++;
    t[b]++;
    t[c]++;
    int ans = 0;
    for(int i=0; i<t.size(); i++) if( t[i] != 0 ) ans++;
    
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
  int a, b;
  while(cin >> a && cin >> b){
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
      cout << "Possible" << endl;      
    } else {
      cout << "Impossible" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll inf = 12345678999999;
const ll wall = -12345678;
int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	int sum = 0;
	vector<int> vi;
	for(int i = min(a,b);i>=1;i--)
	{
		if(a%i == 0&&b%i == 0)
			vi.push_back(i);
	}
	cout<<vi[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX_K 5000
#define MAX_Q 5000

int d[MAX_K];

void cnt_j(int d[], int k){
	int n, x, m;
	int d_moded[MAX_K];
	int i, quo_k, rem_k;
	long long cnt_not_j = 0;
	long long max_a;

	scanf("%d %d %d", &n, &x, &m);

	max_a = x;
	quo_k = (n-1) / k;
	rem_k = (n-1) % k;
	for(i=0; i<k; i++){
		d_moded[i] = d[i] % m;
		if(d_moded[i] == 0){
			cnt_not_j += quo_k + (i < rem_k);
		}
		max_a += (long long)d_moded[i]*(quo_k + (i < rem_k));
	}

	cnt_not_j += max_a/m - x/m;
	printf("%lld\n", n-1-cnt_not_j);
}

int main(){
	int k, q;
	int i;

	scanf("%d %d", &k, &q);
	for(i=0; i<k; i++){
		scanf("%d", d+i);
	}
	for(i=0; i<q; i++){
		cnt_j(d, k);
	}

	return 0;
}


Measured memory_bytes: 256
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

using Bit = bitset<16>;

signed main()
{
  int N, M;
  cin >> N >> M;

  vector<int> s[11];
  int p[11];

  rep(i, 0, M) {
    int k; cin >> k;
    s[i].resize(k);
    rep(j, 0, k) {
      cin >> s[i][j];
      --s[i][j];
    }
  }

  rep(i, 0, M) cin >> p[i];

  auto countOn = [&](int switchID, const Bit &bit) {
    const auto sw = s[switchID];
    int cnt = 0;
    for (int idx : sw) { if (bit[idx]) ++cnt; }
    return cnt;
  };

  auto isAll = [&](const Bit &bit) {
    rep(i, 0, M) {
      if (countOn(i, bit) % 2 != p[i]) return false;
    }
    return true;
  };

  int ans = 0;
  rep(b, 0, 1 << N) {
    Bit bit(b);
    if (isAll(b)) ++ans;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
loop do
  n,t,l,b=gets.chomp.split(/ /).map{|i| i.to_i}
  break if (n|t|l|b)==0
  dice=Array.new(n+1,0)
  for i in 0..l-1
    dice[gets.chomp.to_i]=-1  #lose
  end
  for i in 0..b-1
    dice[gets.chomp.to_i]=1   #back
  end
  
  p=Array.new(n+1).map{Array.new(t+2,0)}
  p[0][0]=1
  ans=0
  for k in 1..t
    for i in 0..n-1
      for dc in 1..6
        j=i+dc
        if j>n
          j=2*n-j
        end
        if dice[j]==-1
          p[j][k+1]+=p[i][k-1]/6.0
        elsif dice[j]==1
          p[0][k]+=p[i][k-1]/6.0
          p[j][k]=0
        else
          p[j][k]+=p[i][k-1]/6.0
        end
        if j==n
          ans+=p[i][k-1]/6.0
        end
      end
    end
  end
  puts "%.6f" % ans
end

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

//#define int long long
//#define ll int long long
#define REP(i,n) for(int i=0;i<n;i++)
//#define ALL(vec) (vec).begin(),(vec).end()
//#define vint vector<int>
//#define pint pair<int,int>
//#define vpint vector<pint>
/*
int par[100002];
int rnk[100002];
void init(int n){REP(i,n){par[i]=i;rnk[i]=0;}}
int find(int x){if(par[x]==x){return x;}else{return par[x]=find(par[x]);}}
void unite(int x,int y){x=find(x);y=find(y);if(x==y)return;if(rnk[x]<rnk[y]){par[x]=y;}else{par[y]=x;if(rnk[x]==rnk[y])rnk[x]++;}}
bool same(int x,int y){return find(x)==find(y);}
*/

int a,b;

signed main(){
    cin>>a>>b;
    if(a+b==15)cout<<"+";
    else if(a*b==15)cout<<"*";
    else cout<<"x";
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
int main(){
    int n;
    int cnt = 1;
    std::cin >> n;
    int v[n];
    for(int i=0; i<n; ++i){
        std::cin >> v[i];
    }
    for(int i=0; i<n; ++i){
        for(int j=0; j<i; ++j){
            if(v[j] > v[i]){
                break;
            }else{
                if(j == (i-1)){
                    cnt++;
                }
            }
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int x[110];
vector<int> v,a,b;
int main(){
	int i,n,m,j;
	cin >> n >> m;
	for(i=0;i<m;i++){
		cin >> x[i];
		if(x[i]&1){
			v.push_back(x[i]);
		}
	}
	if(v.size()>2){
		cout << "Impossible" << endl;
		return 0;
	}
	if(v.size()){
		a.push_back(v.back());
		v.pop_back();
	}
	for(i=0;i<m;i++){
		if(!(x[i]&1)) a.push_back(x[i]);
	}
	if(v.size()){
		a.push_back(v[0]);
	}
	for(i=0;i<m;i++){
		cout << a[i] << " ";
	}
	cout << endl;
	if(m==1){
		if(n==1){
			cout << 1 << endl;
			cout << 1 << endl;
		}else{
			cout << 2 << endl;
			cout << 1 << " " << n - 1 << endl;
		}
		return 0;
	}
	b.push_back(a[0] + 1);
	for(i=1;i<m-1;i++){
		b.push_back(a[i]);
	}
	if(a[m - 1]!=1) b.push_back(a[m - 1] - 1);
	cout << b.size() << endl;
	for(i=0;i<b.size();i++){
		cout << b[i] << " ";
	}
	cout << endl;
}

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

#define ll long long 
#define int ll
#define endl "\n"

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.txt", "r", stdin); 
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector <int> a(n);
	for (auto& i:a) cin >> i;
	sort(a.rbegin(), a.rend());
	int cont = 1;
	if (n == 2){
		cout << a.front() << endl;
		return 0;
	}
	int ans = a.front();
	
	for (int i=1; i<n; i++){
		ans += 2*a[i];
		cont += 2;
		if (cont == n-1) break;
		else if (cont == n){
			ans -= a[i];
			cont--;
			break;
		}
	}
	cout << ans << endl;	
		
}

Measured memory_bytes: 4748
import copy

H, W, K = list(map(int, input().split()))
c = [0]*H
for i in range(H):
    char = input()
    c[i] = []
    for j in range(W):
        if char[j] == "#":
            c[i].append(1)
        else:
            c[i].append(0)

count = 0

for i in range(2**H):
    for j in range(2**W):
        d = copy.deepcopy(c)
        i2 = i
        j2 = j
        for k in range(H):
            if i2 & 1:
                d[k] = [0]*W
            i2 >>= 1
        for l in range(W):
            if j2 & 1:
                for m in range(H):
                    d[m][l] = 0
            j2 >>= 1
        s = sum(map(sum, d))
        if s == K:
            count += 1

print(count)

Measured memory_bytes: 9272
#include<stdio.h>

int main(void)
{
  int n,m,x,array[101],i,left=0,right=0,ans;
  scanf("%d %d %d",&n,&m,&x);
  for(i=0;i<m;i++)
    {
      scanf("%d",&array[i]);
    }
  for(i=0;array[i]<x;i++)
    {
      left++;
    }
  for(i=m-1;array[i]>x;i--)
    {
      right++;
    }
  if(left > right)
    {
      ans = right;
    }
  else
    {
      ans = left;
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){

    double N, M;
    cin>>N;
    cin>>M;

    int num = (int)(M / N) + 10;
    int i;
    int ans = 0;

    if (((int)M % (int)N) == 0){
        ans = (int)M / (int)N;
    }else{
        for(i = 1; i < num; i++){
            if (((int)M % i) == 0){
                if ((M / i) >= N){
                    ans = i;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}



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


int main(){
	string a,b;
	cin >> a >> b;
	for(int i=0;i<a.size()-1;i++){
		cout << a[i];
		cout << b[i];
		
	}
	cout << a[a.size()-1];
	if(b.size()==a.size()){
		cout << b[b.size()-1] ;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
int main()
{
	ll s,w;
	cin>>s>>w;
	if(w>=s)
	{
		cout<<"unsafe"<<endl;
	}
	else
	{
		cout<<"safe"<<endl;
	}
	
	return 0;	
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n;ll t[5],ans;char s[200005];
int main()
{
    cin>>(s+1);n=strlen(s+1);
    rep(i,1,n){
        if(s[i]=='A') t[2]++;
        else if(s[i]=='B'&&s[i+1]=='C') {t[1]++,ans+=t[2],i++;continue;}
        else t[1]=t[2]=0;
    }
    cout<<ans;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b,c;
    cin>>a>>b>>c;
    ll d=c-a-b;
    //cout<<d*d;
    if(d>0 && d*d>4*a*b)
        cout<<"Yes";
    else
        cout<<"No";

}
 


Measured memory_bytes: 256
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map+(/ /*atan2$'-$y,$`-$x)x!/^$x $y/,@a),"@b"+($P=6.28319)for@a=<>

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,s;

            string[] word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            int m = a;
            if (b > m) m = b;
            if (c > m) m = c;
            s = a + b + c - m;

            Console.WriteLine(s);

            //Console.ReadKey();
        }
    }
}


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

const int MOD = 1000000007;

int main() {
  ll s;
  cin >> s;
  ll dp[2001];                // oooo|ooooooo i番目の右に仕切り
  dp[0] = dp[1] = dp[2] = 0;  // 数列なし
  dp[3] = dp[4] = dp[5] = 1;  // 数列はひとつだけ(仕切りが右端)
  dp[6] = dp[3] + 1;
  // dp[7] = dp[4] + dp[3] = dp[4] + dp[6];
  // dp[8] = dp[5] + dp[4] + dp[3] = dp[5] + dp[7];
  // dp[n] = dp[n-3] + dp[n-1];
  if (s >= 7) {
    for (int i = 7; i <= s; i++) {
      dp[i] = dp[i - 3] + dp[i - 1];
      dp[i] %= MOD;
    }
  }

  cout << dp[s] << endl;
}

Measured memory_bytes: 3656
# SUN,MON,TUE,WED,THU,FRI,SAT 
s = gets.chomp

if s =="SUN"
  puts 7
elsif s == "MON"
  puts 6
elsif s == "TUE"
  puts 5
elsif s == "WED"
  puts 4
elsif s == "THU"
  puts 3
elsif s == "FRI"
  puts 2
elsif s == "SAT"
  puts 1
end

Measured memory_bytes: 1788
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> minus = new ArrayList<>();
        long sumM = 0;
        long sumP = 0;
        int[] a= new int[n];
        int[] b= new int[n];
        PriorityQueue<Integer> plus = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            int a1 = a[i];
            int b1 = b[i];
            if (b1 > a1) {
                minus.add(b1-a1);
                sumM+=(long)(b1-a1);
            }
            if (a1 > b1) {
                plus.add(a1-b1);
                sumP+=(long)(a1-b1);
            }
        }
        if (sumM > sumP) {
            System.out.println(-1);
            return;
        }
        if (sumM == 0) {
            System.out.println(0);
            return;
        }

        int carry = 0;
        int change = minus.size();
        for (int m : minus) {
            while (carry < m) {
                carry += plus.poll();
                change++;
            }
            carry -= m;
        }
        System.out.println(change);
    }
}

Measured memory_bytes: 61492
from math import ceil

H, N = map(int, input().split())
magic = []
for _ in range(N):
    a, b = map(int, input().split())
    magic.append((a, b))

"""
ナップサック問題の典型類題。
dp[i][j] = (magicを0〜i番目まで用いて体力jのモンスターを倒すのに必要なmpの最小値)
とすると、
    dp[i][j] = min(dp[i-1][j], dp[i][j-a_i] + b_i)
これでdpテーブルは全部埋められる。
"""

dp = [[float("inf")] * (H + 1) for _ in range(N)]
# まずは初期化
for i in range(N):
    dp[i][0] = 0
for j in range(H + 1):
    a0, b0 = magic[0]
    dp[0][j] = b0 * ceil(j / a0)

# ここからdp
for i in range(1, N):
    for j in range(1, H + 1):
        a, b = magic[i]
        if j - a < 0:
            dp[i][j] = min(dp[i - 1][j], b)
        else:
            dp[i][j] = min(dp[i-1][j], dp[i][j-a] + b)

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


Measured memory_bytes: 367424