akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
using ll = long long;
int main() {
	int c[3][3];
	vector<int> a(3), b(3);
	rep(i, 3) {
		rep(j, 3) {
			cin >> c[i][j];
		}
	}
	a[0] = 0;
	rep(i, 3)b[i] = c[0][i] - a[0];
	rep(i, 3)a[i] = c[i][0] - b[0];
	rep(i, 2) {
		rep(j, 2) {
			if (c[i + 1][j + 1] != a[i + 1] + b[j + 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	cin >> c[0][0];
}


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

using namespace std;

#define si(a) scanf("%d",&a)
#define f first
#define s second
#define mp(a,b) make_pair(a,b)
#define MAX 200005

long long kombe[MAX],cnt[MAX],dic[MAX],arek[MAX];

int main()
{
    //freopen("input.txt","r",stdin);
    int n,m,i,now,prv;
    si(n);si(m);
    long long ans=0;
    for(i=0;i<n;i++){
        si(now);now--;
        int nn=now;
        if(i){
            if(prv>now)
                now+=m;
            ans+=(now-prv);
            cnt[prv+1]++;
            dic[now]++;
            arek[now]+=(now-prv-1);
        }
        prv=nn;
    }
    long long str=0,tmp=0;
    long long mx=0;
    for(i=0;i<MAX;i++){
        tmp+=str;
        str+=cnt[i];
        kombe[i%m]+=tmp;
        str-=dic[i];
        tmp-=arek[i];
    }
    for(i=0;i<m;i++)mx=max(mx,kombe[i]);
    cout<<ans-mx<<endl;
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1<<27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> s(N);
    rep(i, N) cin >> s[i];
    pt((N + K - 3) / (K - 1));

}

Measured memory_bytes: 1024
n = int(input())
count = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(n):
    count[input()] += 1
print('AC x {}'.format(count['AC']))
print('WA x {}'.format(count['WA']))
print('TLE x {}'.format(count['TLE']))
print('RE x {}'.format(count['RE']))

Measured memory_bytes: 9196
using System;
using System.Linq;
using System.Text;

namespace ALDS1_6_B_Partition
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int dataCount = int.Parse (Console.ReadLine ());
			int[] numArray = new int[dataCount];
			numArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			//process
			int index = Partition (numArray, 0, numArray.Length - 1);

			//output
			string[] data = Array.ConvertAll (numArray, num => num.ToString ());
			data[index] = "[" + data[index] + "]";
			string result = string.Join (" ", data);

			Console.WriteLine (result);
		}

		static int Partition ( int[] numArray, int firstIndex, int lastIndex )
		{
			int lastItem = numArray[lastIndex];
			int index = firstIndex - 1;

			for (int lp = firstIndex; lp < lastIndex; lp++)
			{
				if (numArray[lp] <= lastItem)
				{
					index++;

					var tmp = numArray[index];
					numArray[index] = numArray[lp];
					numArray[lp] = tmp;
				}
			}

			var tmp2 = numArray[index + 1];
			numArray[index + 1] = numArray[lastIndex];
			numArray[lastIndex] = tmp2;

			return index + 1;
		}
	}
}

Measured memory_bytes: 21208
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static int n = NextInt();
    static int k = NextInt();
    static int[] D = new int[k];

    static void Main()
    {
        for (var i = 0; i < k; i++)
        {
            D[i] = NextInt();
        }

        for (var i = 0; ; i++)
        {
            DFS("", i);
        }
    }

    static void DFS(string s, int m)
    {
        if (s != "" && int.Parse(s) >= n)
        {
            WriteLine(s);
            Environment.Exit(0);
        }
        if (s.Length == m)
        {
            return;
        }
        for (var i = 0; i <= 9; i++)
        {
            if (!D.Contains(i))
            {
                DFS(i.ToString() + s, m);
            }
        }
    }

    static int NextInt()
    {
        return int.Parse(NextString());
    }

    static string NextString()
    {
        var result = new List<char>();
        while (true)
        {
            int next = Read();
            if (next < 0)
            {
                break;
            }
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
            {
                result.Add(nextChar);
            }
            else if (nextChar != '\r')
            {
                break;
            }
        }
        return string.Join("", result);
    }
}

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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

signed main() {
	int K, A, B;
	cin >> K >> A >> B;

	int n = 0;
	bool res = true;
	while (1) {
		n++;
		int a = K * n;
		if (a < A) continue;
		if (a > B) {
			res = false;
			break;
		} else {
			res = true;
			break;
		}
	}

	if (res == true) cout << "OK" << endl;
	else 			 cout << "NG" << endl;


}


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  vector<ll> beki2;
  ll i=1;
  while(i<=2e9){
    beki2.push_back(i);
    i*=2;
  }
  reverse(all(beki2));
  int n; cin >> n;
  multiset<ll> st;
  rep(i,n){
    int a; cin >> a;
    st.insert(a);
  }
  ll ans=0;
  while(st.size()){
    int x=*rbegin(st);
    st.erase(st.find(x));
    rep(j,beki2.size()){
      if(st.count(beki2[j]-x)){
        st.erase(st.find(beki2[j]-x));
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12972
n=int(input())
t=[int(input()) for i in range(n)]
def gcd(a, b):
  if(a%b==0):
    return b
  else:
    return gcd(b, a%b)

for i in range(1, n):
  t[i]=t[i]*t[i-1]//gcd(t[i], t[i-1])
print(t[n-1])

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EDP_B solver = new EDP_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class EDP_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] h = new int[n + 1];
            int[] cost = new int[100010];
            Arrays.fill(cost, Integer.MAX_VALUE);
            cost[0] = 0;
            cost[1] = 0;
            for (int i = 1; i <= n; i++) {
                h[i] = in.nextInt();

            }


            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= k; j++) {
                    if (i + j <= n) {
                        cost[i + j] = Math.min(cost[i + j], cost[i] + Math.abs(h[i + j] - h[i]));
                    }
                }
            }

            out.print(cost[n]);
        }

    }
}



Measured memory_bytes: 63208
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  vector<ll> ab;
  rep(i, x)rep(j, y) ab.push_back(a[i] + b[j]);
  sort(ab.rbegin(), ab.rend());
  ab.resize(k);

  vector<ll> abc;
  rep(i, ab.size())rep(j, z) abc.push_back(ab[i] + c[j]);
  sort(abc.rbegin(), abc.rend());
  rep(i, k) cout << abc[i] << endl;
}


Measured memory_bytes: 43112
#include <bits/stdc++.h>
    #define pb push_back
    #define all(a) a.begin(), a.end()
    #define sz(a) (int)a.size()
    #define x first
    #define y second
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef pair<int, int>pii;
    const int maxn=1e5+100;
    int n, g;
    int p[15], c[15];
    int ans=INT_MAX;
    int main()
    {
        ios_base::sync_with_stdio(false), cin.tie(0);
        cin>>n>>g;
        for(int i=0; i<n; i++)
            cin>>p[i]>>c[i];
        vector<int>v;
        for(int i=0; i<n; i++)
            v.pb(i);
        do
        {
            int cur=0;
            int res=0;
            for(int i=0; i<n; i++)
            {
                int need=g-cur;
                if(need>p[v[i]]*(v[i]+1)*100)
                {
                    cur+=p[v[i]]*(v[i]+1)*100;
                    cur+=c[v[i]];
                    res+=p[v[i]];
                    if(cur>=g)
                    {
                        ans=min(ans, res);
                        break;
                    }
                }
                else
                {
                    res+=ceil(need/(double)((v[i]+1)*100));
                    ans=min(ans, res);
                    break;
                }
            }
        }while(next_permutation(all(v)));
        cout<<ans<<"\n";
        return 0;
    }


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

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


int func(int ind,int n,int k,vector<int> &v)
{
    if(ind==n)
    {
        return 0;
    }
    
    if(dp[ind]!=-1)
    {
        return dp[ind];
    }
   
    dp[ind]=INT_MAX;   
    for(int i=1;i<=k;i++)
    {
        if(ind+i<=n)
        {
            dp[ind]=min(dp[ind],abs(v[ind]-v[ind+i])+func(ind+i,n,k,v));
        }
    }
    
    return dp[ind];
}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    
    cout<<func(0,n-1,k,v);
    
    return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    vector<double> p(n), q(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        q[i + 1] = q[i] + (p[i] + 1) / 2;
    }
    double ans = 0;
    for (int i = 0; i < n - k + 1; i++) {
        ans = max(ans, q[i + k] - q[i]);
    }
    printf("%.10f", ans);
    return 0;
}

Measured memory_bytes: 3328
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger a = sc.nextBigInteger();
		BigInteger b = sc.nextBigInteger();
		BigInteger n = sc.nextBigInteger();
		BigInteger x = b.subtract(BigInteger.ONE).min(n);
		sc.close();
		System.out.println(a.multiply(x).divideAndRemainder(b)[0].toString());

		// (a * x) / b

	}
}


Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

 
ll n,q;
vector<tuple<ll,ll,ll>> v;//(time,type,value)
//type -1:add ,0:delete ,1:calc
multiset<ll> lt;
Vi ans;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>q;
    ans.resize(q,-1);
    ll s,t,x;
    rep(i,n){
        cin>>s>>t>>x;
        v.pb(make_tuple(s-x,-1,x));
        v.pb(make_tuple(t-x,0,x));
    }
    rep(i,q){
        cin>>x;
        v.pb(make_tuple(x,1,i));
    }
    sort(all(v));
    rep(i,v.size()){
        ll typ = get<1>(v[i]) , val = get<2>(v[i]) ,time = get<0>(v[i]);
        if(typ == -1){
            lt.insert(val);
        }else if(typ == 0){
            lt.erase(lt.lower_bound(val));
        }else{
            if(!lt.empty())ans[val] = *lt.begin();
        }
    }
    rep(i,q)print(ans[i]);
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    int ptr = 1;

    REP1 (i, N)
    {
        int a;
        cin >> a;
        if (a == ptr)
            ptr++;
    }

    cout << (ptr == 1 ? -1 : N - (ptr - 1)) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main()
{
	char a[3],b[3],c[3];
	int i;
	for(i=0;i<3;i++)
		cin>>a[i];
	for(i=0;i<3;i++){
		cin>>b[i];
	}
	for(i=0;i<3;i++)
		cin>>c[i];

	cout<<a[0]<<b[1]<<c[2]<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define LL long long
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL LLINF = 1LL << 60;

int main(void) {
	double N, T, A;
	cin >> N >> T >> A;

	vector<double> H(N);
	rep(i, N) cin >> H[i];

	int ans = 0;
	rep(i, N) {
		double temperature = T - H[i] * 0.006;
		double ans_temperature = T - H[ans] * 0.006;
		if (abs(A - temperature) < abs(A - ans_temperature)) {
			ans = i;
		}
	}

	cout << ++ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{  
   int a, b, c,t=0;
   scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b!=c) t=1;
    if(b==c&&c!=a) t=1; 
    if(c==a&&a!=b) t=1;
    if(t==1) puts("Yes");  
    else puts("No");
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

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

  vector<int> a(N);
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    a.at(i) = L + i;
    sum += L + i;
  }
  
  int ans;
  int m = INF;
  for (int i = 0; i < N; i++)
  {
    int x = sum - a.at(i);
    if (chmin(m, abs(sum - x))) ans = x;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define X first
#define Y second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
#define fe(i, start, end) for (lli i = start; i <= end; ++i)
#define L(T)  \
    lli T;    \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
int main()
{
    FASTIO
    lli n, k, flag = 0;
    cin >> n;
    while (n)
    {
        k = n % 10;
        if (k == 7)
            flag = 1;
        n = n / 10;
    }
    if (flag)
        cout << "Yes"
             << "\n";
    else
    {
        cout << "No"
             << "\n";
    }

    return 0;
}

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

void code()
{
    ll x,k,d;
    cin>>x>>k>>d;
    if(x>=0)
    {
        ll diff=x;
        ll mov=diff/d;

        if(k<=mov)
        {
            cout<<x-k*d<<endl;
            return;
        }
        else
        {
            ll lft=k-mov;
            if(lft%2==0)
            {
                cout<<x-mov*d<<endl;
            }
            else
            {
                cout<<abs(x-(mov+1)*d)<<endl;
            }
        }
    }
    else
    {
        ll diff=abs(x);
        ll mov=diff/d;

        if(k<=mov)
        {
            cout<<abs(x+k*d)<<endl;
        }
        else
        {
            ll lft=k-mov;
            if(lft%2==0)
            {
                cout<<abs(x+mov*d)<<endl;
            }
            else
            {
                cout<<x+(mov+1)*d<<endl;
            }
        }
    }

}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector< vector<int> > A;
vector<P> q; // Match queue

// Check the remaining matches. If match can be made, push it to queue.
void check(int i) {
  if (A[i].size() == 0) { return; }
  int j = A[i].back();
  if (A[j].back() == i) {
    if (i > j) { swap(i, j); }  // Force i < j
    q.emplace_back(i, j);
  }
}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  A.assign(N, vector<int>(N-1));
  rep(i, N) {
    rep(j, N-1) {
      cin >> A[i][j];
      --A[i][j];
    }
    reverse(all(A[i]));
  }

  // Push first matches.
  rep(i, N) {
    check(i);
  }

  int day = 0;
  while (q.size() > 0) { // Repeat until match que
    sort(all(q));
    q.erase(unique(all(q)), q.end());

    vector<P> prevQ = q;
    q.resize(0);
    for (auto p : prevQ) {
      A[p.first].pop_back(); // pop match
      A[p.second].pop_back(); // pop match
    }
    for (auto p : prevQ) {
      check(p.first);
      check(p.second);
    }

    ++day;
  }

  // Check the remaining of A
  rep(i, N) {
    if (A[i].size() != 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << day << endl;
}


Measured memory_bytes: 6272
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] a = new int [100];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		System.out.print(a[0]);
		for (int i = 1; i < N; i++) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
		
		int j = 0;
		int t = 0;
		for (int i = 1; i < N; i++) {
			t = a[i];
			j = i - 1;
			while (j >= 0 && a[j] > t) {
				a[j+1] = a[j];
				j--;
			}
			a[j+1] = t;
			
			System.out.print(a[0]);
			for (int k = 1; k < N; k++) {
				System.out.print(" " + a[k]);
			}
			System.out.println();
		}
	}
}




Measured memory_bytes: 30164
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;
  for(int i = 0;i < w + 2;i++) {
    cout << '#';
  }
  cout << endl;
  char a;
  for(int i = 0;i < h;i++) {
    cout << '#';
    for(int j = 0;j < w;j++) {
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }
  for(int i = 0;i < w + 2;i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = "";
        int[] cnt = new int[26];

        while (scan.hasNext()) {
            str = scan.nextLine();
            str = str.toLowerCase();
            char[] c = str.toCharArray();
            for (int i = 0; i < c.length; i++) {
                if ('a' <= c[i] && c[i] <= 'z') {
                    cnt[c[i] - 'a']++;
                }
            }
        }
        for (int i = 0; i < 26; i++) {
            System.out.println(((char)(i + 'a')) + " : " + cnt[i]);
        }
    }
}

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

int main() {
  int N;
  int ans = 0;
  cin >> N;
  vector<int> tako(N);
  for (int i=0; i < N; i++) {
    cin >> tako.at(i);
  }
  for (int i=0; i < N; i++) {
    for (int j=i+1; j < N; j++) {
      ans += tako.at(i) * tako.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define U 1	//上
#define D 2	//下
#define S 3 //南 
#define E 4 //東
#define N 5 //北
#define W 6 //西


int d1=U , d2=S , d3=E;		
int sum = 0;


void West(void){

	switch(d1){

	case U:
		d1 = W;
		break;

	case W:
		d1 = D;
		break;

	case D:
		d1 = E;
		break;

	case E:
		d1 = U;
		break;

	}
	
	switch(d2){

	case U:
		d2 = W;
		break;

	case W:
		d2 = D;
		break;

	case D:
		d2 = E;
		break;

	case E:
		d2 = U;
		break;

	}

	
	switch(d3){

	case U:
		d3 = W;
		break;

	case W:
		d3 = D;
		break;

	case D:
		d3 = E;
		break;

	case E:
		d3 = U;
		break;

	}


}
void East(void){

	switch(d1){

	case U:
		d1 = E;
		break;

	case W:
		d1 = U;
		break;

	case D:
		d1 = W;
		break;

	case E:
		d1 = D;
		break;

	}
	
	switch(d2){

	case U:
		d2 = E;
		break;

	case W:
		d2 = U;
		break;

	case D:
		d2 = W;
		break;

	case E:
		d2 = D;
		break;

	}

	
	switch(d3){

	case U:
		d3 = E;
		break;

	case W:
		d3 = U;
		break;

	case D:
		d3 = W;
		break;

	case E:
		d3 = D;
		break;

	}

}
void North(void){

	switch(d1){

	case U:
		d1 = N;
		break;
	case N:
		d1 = D;
		break;
	case D:
		d1 = S;
		break;
	case S:
		d1 = U;
		break;

	}
	switch(d2){

	case U:
		d2 = N;
		break;
	case N:
		d2 = D;
		break;
	case D:
		d2 = S;
		break;
	case S:
		d2 = U;
		break;

	}
	switch(d3){

	case U:
		d3 = N;
		break;
	case N:
		d3 = D;
		break;
	case D:
		d3 = S;
		break;
	case S:
		d3 = U;
		break;

	}


}
void South(void){

		switch(d1){

	case U:
		d1 = S;
		break;
	case N:
		d1 = U;
		break;
	case D:
		d1 = N;
		break;
	case S:
		d1 = D;
		break;

	}
	switch(d2){

	case U:
		d2 = S;
		break;
	case N:
		d2 = U;
		break;
	case D:
		d2 = N;
		break;
	case S:
		d2 = D;
		break;

	}
	switch(d3){

	case U:
		d3 = S;
		break;
	case N:
		d3 = U;
		break;
	case D:
		d3 = N;
		break;
	case S:
		d3 = D;
		break;

	}
}
void Right(void){

	if(d1 == S||d1 == E||d1 == N||d1 == W){
		d1--;
		if(d1 == 2)
			d1 = W;
	}
	if(d2 == S||d2 == E||d2 == N||d2 == W){
		d2--;
		if(d2 == 2)
			d2 = W;
	}
	if(d3 == S||d3 == E||d3 == N||d3 == W){
		d3--;
		if(d3 == 2)
			d3 = W;
	}

}
void Left(void){

	if(d1 == S||d1 == E||d1 == N||d1 == W){
		d1++;
		if(d1 == 7)
			d1 = S;
	}
	if(d2 == S||d2 == E||d2 == N||d2 == W){
		d2++;
		if(d2 == 7)
			d2 = S;
	}
	if(d3 == S||d3 == E||d3 == N||d3 == W){
		d3++;
		if(d3 == 7)
			d3 = S;
	}
}

void Sum(void){

	if(d1 == U)
		sum += 1;
	else if(d1 == D)
		sum += 6;
	else if(d2 == U)
		sum += 2;
	else if(d2 == D)
		sum += 5;
	else if(d3 == U)
		sum += 3;
	else if(d3 == D)
		sum += 4;

}

int main(void){

	int n,i;

	char s[6];


	while(1){

		sum = 0;
		d1=U , d2=S , d3=E;
		
		scanf("%d",&n);
		if(n==0)
			break;

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

			scanf("%s",s);

			if(strcmp(s,"West")==0){
				West();
			}
			else if(strcmp(s,"East")==0){
				East();
			}
			else if(strcmp(s,"North")==0){
				North();
			}
			else if(strcmp(s,"South")==0){
				South();
			}
			else if(strcmp(s,"Right")==0){
				Right();
			}
			else if(strcmp(s,"Left")==0){
				Left();
			}


			Sum();
		}

		printf("%d\n",sum+1);

	}


	return 0;
}
			

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int a[100100];
int mx = -1,mi = INF;
void fail(){
	cout << "No" << endl;
	exit(0);
}
int main(){
	cin >> N;
	for(int i=0;i<N;i++)cin >> a[i];
	for(int i=0;i<N;i++){
		mx = max(mx,a[i]);
		mi = min(mi,a[i]);
	}
	if(mx-mi>1)fail();
	if(mx>mi){
		int A = 0;
		for(int i=0;i<N;i++){
			if(a[i]==mi)A++;
		}
		int X = mx;
		if(A>=X)fail();
		if(2*X-A>N)fail();
		cout << "Yes" << endl;
	}else{
		if(2*mx>N&&mx+1!=N)fail();
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x; cin >> k >> x;
    set<int> ans;
    for(int i = 1; i < k; i++)
    {
        ans.insert(x + i);
        ans.insert(x - i);
    }
    ans.insert(x);
    for(int x : ans) cout << x << " "; cout << endl;
    return 0;
}



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

/*
	dp[i][W] = max sum i can get with w weight using first i elements.
	dp[i][w] = max(dp[i - 1][w], v[i] + dp[i - 1][w - w[i]])
	answer lies in dp[n - 1][W];
	base case: dp[0][0] = 
*/
const int max_row = 105;
const  int max_col = 1e5 + 5;

long long int dp[max_row][max_col];

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

	memset(dp, 0, sizeof(dp));

	vector < int > val(N);
	vector < int > weights(N);

	for(int i = 0; i < N; ++i) {
		cin >> weights[i] >> val[i];
	}
	for(int j = 0; j <= W; ++j) {
		if(j >= weights[0])
			dp[0][j] = val[0];
	}

	for(int i = 1; i < N; ++i) {
		for(int j = 0; j <= W; ++j) {
			if(j >= weights[i]) {
				dp[i][j] = max(dp[i - 1][j], val[i] + dp[i - 1][j - weights[i]]);
				//cout << i << " " << j << " " << dp[i][j] << endl;

			}
			else
				dp[i][j] = dp[i - 1][j];
		}
	}

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

Measured memory_bytes: 82304
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll k,a,b;
    cin>>k>>a>>b;
    if(a%k==0||b%k==0){
        cout<<"OK"<<endl;
        return 0;
    }
    if(a/k!=b/k){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        int[][] bingoArray = new int[3][3];
        for (int i = 0; i < bingoArray.length; i++) {
            for (int k = 0; k < bingoArray.length; k++) {
                bingoArray[i][k] = scanner.nextInt();
            }
        }

        int inputSize = scanner.nextInt();

        int counter = 0;
        for (int h = 0; h < inputSize; h++) {
            int current = scanner.nextInt();

            for (int i = 0; i < bingoArray.length; i++) {
                for (int k = 0; k < bingoArray.length; k++) {
                    if (bingoArray[i][k] == current) {
                        bingoArray[i][k] = -1;
                        counter++;
                    }
                }
            }
        }

        String answer;
        if (counter < 3) {
            answer = "No";
        } else {
            if (bingoArray[0][0] == -1 && bingoArray[0][1] == -1 && bingoArray[0][2] == -1) {
                answer = "Yes";
            } else if (bingoArray[1][0] == -1 && bingoArray[1][1] == -1 && bingoArray[1][2] == -1) {
                answer = "Yes";
            } else if (bingoArray[2][0] == -1 && bingoArray[2][1] == -1 && bingoArray[2][2] == -1) {
                answer = "Yes";
            } else if (bingoArray[0][0] == -1 && bingoArray[1][0] == -1 && bingoArray[2][0] == -1) {
                answer = "Yes";
            } else if (bingoArray[0][1] == -1 && bingoArray[1][1] == -1 && bingoArray[2][1] == -1) {
                answer = "Yes";
            } else if (bingoArray[0][2] == -1 && bingoArray[1][2] == -1 && bingoArray[2][2] == -1) {
                answer = "Yes";
            } else if (bingoArray[0][0] == -1 && bingoArray[1][1] == -1 && bingoArray[2][2] == -1) {
                answer = "Yes";
            } else if (bingoArray[2][0] == -1 && bingoArray[1][1] == -1 && bingoArray[0][2] == -1) {
                answer = "Yes";
            } else {
                answer = "No";
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23760
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

ll burgerDan[100];
ll burgerPatty[100];

ll yo(ll n ,ll zan)
{
    if(n == 0)
    {  
        //BP PPBの先頭
        //BP,P , "" のいずれかの状態
        if(zan >= 1)return 1;
        else return 0;
    }
    else if(zan <= burgerDan[n - 1] + 1)
    {
        ///末尾のbを含めた//なぜzan -1するのか←末尾のBを削除ここで、目的の形にする
        //レベルN = B(レベルN-1)P(レベルN-1)B
        //レベルN-1 = B(レベルN-2)P(レベルN-2)B　なので、末尾がBBになる。zan-1して末尾Bにする
        return yo(n-1,zan - 1);
    }
    else if(zan == burgerDan[n - 1] + 2)
    {
        return burgerPatty[n-1]+ 1;
    }
    else//2 + burgerDan[n-1] < zan 末尾のB,中間のP
    {
        return burgerPatty[n - 1] + 1 + yo(n - 1, zan - (burgerDan[n-1] + 2));
    }
}

//        tmp = stoi(S.substr(i,3));
int main(){


    ll N,X,resP,re;

    cin >> N >> X;

//    burgerDan.resize(N);
//    burgerPatty.resize(N);

    burgerDan[0] = 1;
    burgerPatty[0] = 1;
    ll i;
    for(i = 1; i < N; i++)
    {
        burgerDan[i] = burgerDan[i-1]*2 + 3;
        burgerPatty[i] = burgerPatty[i-1]*2 + 1;
    }
    resP = yo(N,X);


    cout << resP << endl;

    return 0;
}

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

int main()
{
    string alp,s,ans;
    int n=0,m=0;
    alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin >>n>> s;
    char c;
    for(int i = 0;i<s.length();i++){
        c = s[i];
        for(int j = 0;j<alp.length();j++){
            if(alp[j]==c){
                ans+=alp[j+26+n];
                break;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};



int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int xl;
	in(xl);
	if(xl<30)out("No");
	else out("Yes");
	return 0;
}


Measured memory_bytes: 3648
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
INF = 10 ** 3
(H, W) = list(map(int,input().split()))
# print(H,W)

S = []
N = H * W
c = [[INF for j in range(N)] for u in range(N)]
d = [[INF for j in range(H*W)] for u in range(H*W)]

for k in range(N):
    c[k][k] = 0
    d[k][k] = 0

for i in range(H):
    S.append(input())

#print(S)

def vindex(i,j):
    global W
    return W * (i-1) + j -1

# print(vindex(H,W))
for i in range(1,H+1):
    for j in range(1,W+1):
        index = vindex(i,j)
        s = S[i-1][j-1]
        # print(index,s)
        if i != 1:
            index_t = vindex(i-1,j)
            sup = S[i-2][j-1]
            if ( s == "." and sup == "."):
                d[index][index_t]=1 
                d[index_t][index]=1
                
        if i != H:
            index_t = vindex(i+1,j)
            sup = S[i][j-1]
            if ( s == "." and sup == "."):
                d[index][index_t]=1 
                d[index_t][index]=1
        if j != 1:
            index_t = vindex(i,j-1)
            sup = S[i-1][j-2]
            if ( s == "." and sup == "."):
                d[index][index_t]=1 
                d[index_t][index]=1
        if j != W:
            index_t = vindex(i,j+1)
            sup = S[i-1][j]
            if ( s == "." and sup == "."):
                d[index][index_t]=1 
                d[index_t][index]=1

#print("D",d)


for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j] , d[i][k]+d[k][j])
    #print(k,d)

ans = 0 
for i in range(N):
    for j in range(N):

        if (d[i][j] != INF and d[i][j] > ans):
            ans = d[i][j]

print(ans)


Measured memory_bytes: 45980
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void inline add(int&,int);
int mul(int,int);
int powz(int,int);
int sub(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	int a,b;
	cin>>a>>b;
	cout<<max({a*b,a+b,a-b});
	
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void inline add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define qmax(x,y) (x=max(x,y));
using namespace std;

typedef long long ll;
const int Maxn=110;
const ll mod=1000000007;

int n;
ll k,a[Maxn][Maxn],ans[Maxn][Maxn],c[Maxn][Maxn];

void mul1() {
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				c[i][j]+=ans[i][k]*a[k][j]%mod;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) ans[i][j]=c[i][j]%mod;
}

void mul2() {
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				c[i][j]+=a[i][k]*a[k][j]%mod;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) a[i][j]=c[i][j]%mod;
}

void powp() {
	for(int i=1;i<=n;i++) ans[i][i]=1;
	while(k) {
		if(k&1) mul1();
		mul2();
		k>>=1;
	}
}

int main() {
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) scanf("%lld",&a[i][j]);
	powp();
	ll sum=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) sum+=ans[i][j];
	printf("%lld",sum%mod);
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    if(B % A == 0){
        cout << A + B << endl;
    }else{
        cout << B - A << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1E8)
    dp = [INF for _ in range(2**N)]
    A = [None for _ in range(M)]
    for j in range(M):
        a, b = map(int, input().split())
        C = list(map(int, input().split()))
        ind = 0
        for c in C:
            ind += 2**(c-1)
        A[j] = (ind, a)
        dp[ind] = min(dp[ind], a)

    Id = [i for i in range(2**N)]
    Id.sort(key=lambda x: bin(x).count('1'))

    for x in Id:
        for ind, a in A:
            dp[x|ind] = min(dp[x|ind], dp[x]+a)
    if dp[2**N-1] >= INF:
        print(-1)
    else:
        print(dp[2**N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
import heapq
from collections import defaultdict, deque
# from math import ceil, factorial, gcd
from itertools import accumulate, permutations
import sys
import bisect


sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))
# ----------

N = ii()
A = []
for i in range(N):
    A.append(ii())

d = deque()

for a in A:
    p = bisect.bisect_left(d, a)
    if p == 0:
        d.appendleft(a)
        continue
    d[p-1] = a

print(len(d))


Measured memory_bytes: 8112
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
  int n,ans=0,x=0;
  cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
    if(i==0){
    x=num[i];
    ans++;
    }
    else{
      if(x<=num[i]){
        ans++;
        x=num[i];
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*25^4
*/
int main(){
  ll N,W; cin>>N>>W;
  vector<ll> A(1,0),B(1,0),C(1,0),D(1,0);
  ll w1,v1; cin>>w1>>v1; A.emplace_back(v1);
  for(ll i=1; i<N; i++){
    ll a,b; cin>>a>>b;
    if(a==w1) A.emplace_back(b);
    else if(a==w1+1) B.emplace_back(b);
    else if(a==w1+2) C.emplace_back(b);
    else if(a==w1+3) D.emplace_back(b);
  }
  sort(A.begin(), A.end(), greater<ll>());
  sort(B.begin(), B.end(), greater<ll>());
  sort(C.begin(), C.end(), greater<ll>());
  sort(D.begin(), D.end(), greater<ll>());
  //累積和にする
  ll asz=A.size(), bsz=B.size(), csz=C.size(), dsz=D.size();
  for(ll i=1; i<asz; i++) A[i]+=A[i-1];
  for(ll i=1; i<bsz; i++) B[i]+=B[i-1];
  for(ll i=1; i<csz; i++) C[i]+=C[i-1];
  for(ll i=1; i<dsz; i++) D[i]+=D[i-1];
  ll ans=0;
  for(ll a=0; a<asz; a++){
    for(ll b=0; b<bsz; b++){
      for(ll c=0; c<csz; c++){
        for(ll d=0; d<dsz; d++){
          ll w=a*w1+b*(w1+1)+c*(w1+2)+d*(w1+3);
          if(w>W) continue;
          ll val=0;
          if(a>0) val+=A[a-1];
          if(b>0) val+=B[b-1];
          if(c>0) val+=C[c-1];
          if(d>0) val+=D[d-1];
          ans=max(ans,val);
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), a2(n);
    rep(i,n) cin >> a.at(i);

    copy(a.begin(), a.end(), back_inserter(a2));

    sort(a2.begin(), a2.end(), greater<int>());
    int a_max = a2.at(0);

    rep(i,n){
        if(a.at(i)<a_max) cout << a_max << endl;
        else cout << a2.at(1) << endl;
    }
}

Measured memory_bytes: 3952
import java.util.*;
public class Main{
 
     public static void main(String[] arg){
           Scanner sc = new Scanner(System.in);
           int a =  sc.nextInt();
           int b =  sc.nextInt();
           int h =  sc.nextInt();
           System.out.println((a+b)*h/2);
     }
 
}

Measured memory_bytes: 9804