akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> x(N), y(N);
    rep(i,N) cin >> x[i] >> y[i];

    ll ans = INF;
    rep(i,N){
        rep(j,N){
            rep(k,N){
                rep(l,N){
                    ll x1 = x[i];
                    ll x2 = x[j];
                    ll y1 = y[k];
                    ll y2 = y[l];
                    ll count = 0;
                    rep(n,N){
                        if (x1 <= x[n] && x[n] <= x2 && y1 <= y[n] && y[n] <= y2){
                            count++;
                        }
                    }
                    if (count >= K){
                        ans = min(ans, abs(x2-x1)*abs(y2-y1));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	int a, g;
	cin >> g;
	int ma = g;
	rep(i,n-1){
		cin >> a;
		chmax(ma, a);
		g = gcd(g, a);
	}
	if(ma >= k && k%g == 0) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

char nxt[9][4] = { {'B', 'D', ' ', ' '},
		   {'A', 'C', 'E', ' '},
		   {'B', 'F', ' ', ' '},
		   {'A', 'E', 'G', ' '},
		   {'B', 'D', 'F', 'H'},
		   {'C', 'E', 'I', ' '},
		   {'D', 'H', ' ', ' '},
		   {'G', 'E', 'I', ' '},
		   {'F', 'H', ' ', ' '} };

string s;

int main(){
  while(cin >> s){
    bool can = true;
    for(int i=1;i<s.size();i++){
      bool f = false;
      for(int j=0;j<4;j++){
	if(nxt[s[i-1]-'A'][j] == s[i])f = true;
      }
      if(!f){
	can = false;
	break;
      }
    }
    if(can)cout << s << endl;
  }
}

Measured memory_bytes: 1176
//トポソの唯一性
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;

int main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > adj(n);
    vector<int> d(n, 0);                           //入次数
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;                   //a->bへ有向辺
        d[b]++;
        adj[a].push_back(b);
    }

    queue<int> q;

    //入次数が0の頂点queueに入れる
    for(int i = 0; i < n; i++){
        if(d[i] == 0) q.push(i);                    
    }

    vector<int> ans;

    while(!q.empty()){

        int v = q.front();
        q.pop();
        ans.push_back(v);

        //vから伸びている有向辺をなめる
        for(int i = 0; i < (int)adj[v].size(); i++){
            d[adj[v][i]]--;
            //辺を取り除いた後に入次数が0になったら
            if(d[adj[v][i]] == 0) q.push(adj[v][i]);
        }

    }

    for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
using namespace std;

int main(void){
    string a,b;
    cin >> a >> b;
    int count = 0;
    //int size = SIZE_OF_ARRAY(array1)
    for (int i = 0;i < a.length();i++){
        if ( a[i] != b[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if( s < t ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

int main(){
    int n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;

    vector<int> d(n);
    for(int i=0; i<n; ++i)
        cin >> d[i];
    d.push_back(l);

    double ret = 0.0;
    int carrot = 0;
    int pos = 0;
    int i = 0;
    for(;;){
        if(carrot == 0){
            int len = d[i] - pos;
            ret += len / (double) u;
            pos = d[i];
			++ i;
            ++ carrot;
        }

		-- carrot;
        int nextPos = pos + v * t;
        if(nextPos >= l){
            int len = l - pos;
            ret += len / (double) v;
            break;
        }
		pos = nextPos;

        ret += t;
        while(i < n && d[i] < pos){
            if(carrot < k)
                ++ carrot;
			else{
				int newPos = d[i] + t * v;
				if(newPos > pos){
					ret += (newPos - pos) / (double) v;
					pos = newPos;
				}
			}
            ++ i;
        }
    }

    printf("%.10f\n", ret);

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N;
    cin >> N;
    if(N%1000 == 0){
        cout<<"0"<<endl;
    }else{
        cout << 1000-N%1000 << endl;
    }

    return 0;  
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();

            Console.WriteLine((b / a) < c? (b / a) : c);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,m,ans=0,cnt=0;
	cin >> n >> m;
	long long x[n],y[n],z[n],a[n];
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	for(int i=-1;i<2;i+=2){
		for(int j=-1;j<2;j+=2){
			for(int k=-1;k<2;k+=2){
				cnt=0;
				for(int l=0;l<n;l++){
					a[l]=i*x[l]+j*y[l]+k*z[l];
				}
				sort(a,a+n);
				reverse(a,a+n);
				for(int l=0;l<m;l++){
					cnt+=a[l];
				}
				ans=max(ans,cnt);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[110];
int main()
{
    ll x,k,d;
    cin >> x >> k >> d;
    if(x<0)
    {
        x = -x;
    }
    ll ans=0;
    ll cnt = k - (x-x%d)/d;
    if((x-x%d)/d>=k) ans = x-k*d;
    else
    {
        if(cnt%2==0)    ans = x%d;
        else
        {
            ans = -(x%d-d);
        }
        
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3632
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846
#define FF first
#define SS second

const ll mod = 1000000007;
int main(){
	FASTIO;
	ll n; cin >> n;
	ll a[n]; parseArray(a, n);
	ll pref[n];
	pref[0] = a[0];
	for ( int k = 1; k < n; k++ )
		pref[k] = (pref[k - 1] + a[k]) % mod;
	ll ans = 0;
	for ( int k = 1; k < n; k++ ){
		ans += (pref[k - 1] * a[k]) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int a, b, c;

int main(){
  cin >> a >> b >> c;
  string res = "No";
  if(a == b){
    if(a != c){
      res = "Yes";
    }
  }
  if(b == c){
    if(a != b){
      res = "Yes";
    }
  }
  if(c == a){
    if(b != a){
      res = "Yes";
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    if(n%2){
        cout << 0 << endl;
        return 0;
    }
    //5の数は10の倍数の個数
    int ans = 0;
    int t = 5;
    while(n >= t){
        int tmp = n/t;
        if(t%2)ans += tmp/2;
        else ans += tmp;
        t *= 5;
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

int main() {
    const char YES[] = "YES\n";
    const char NO[] = "NO\n";

    int times = 0;
    scanf("%d", &times);
    for (int i = 0; i < times; ++i) {
        int inputSide[3];
        scanf("%d %d %d", &inputSide[0], &inputSide[1], &inputSide[2]);
        {
            bool finished = false;
            while (!finished) {
                finished = true;

                for (int j = 0; j < 3 - 1; ++j) {
                        if (inputSide[j] < inputSide[j + 1]) {
                        int temp = inputSide[j + 1];
                        inputSide[j + 1] = inputSide[j];
                        inputSide[j] = temp;
                        finished = false;
                    }
                }
            }
        }

        printf(((((inputSide[2] * inputSide[2]) + (inputSide[1] * inputSide[1])) == (inputSide[0] * inputSide[0])) ? YES : NO));
    }

    return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int op(int a, int b) {
  return max(a, b);
}
int e() {
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> A(n); rep(i, n) cin >> A[i];
  segtree<int, op, e> seg(300005);
  rep(i, n) {
    seg.set(A[i], seg.prod(max(0, A[i]-k), min(300005, A[i]+k+1))+1);
  }
  cout << seg.prod(0, 300005) << endk;
  return 0;
}


Measured memory_bytes: 9832
#include <stdio.h>
#include <string.h>
#include <ctype.h>



int main(int argc, const char * argv[]) {
    // insert code here...
    
    int n;
    scanf("%d",&n);
    
    int taro=0,hanako=0;
    
    int i;
    for(i=0;i<n;i++){
        char t[100],h[100];
        scanf("%s %s",t,h);
        int j=0;
        while(1){
            if(j == 100 ||
               (t[j] == '\0' && h[j] == '\0')){
                taro++;
                hanako++;
                break;
            }
            else if(t[j] > h[j]){
                taro+=3;
                break;
            }
            else if(t[j] < h[j]){
                hanako+=3;
                break;
            }
            
            j++;
        }
    }

    printf("%d %d\n",taro,hanako);
    
    return 0;
}

Measured memory_bytes: 596
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(nums):
    return reduce(lcm_base, nums, 1)

N = int(input())
times = [int(input()) for _ in range(N)]
print(lcm(times))

Measured memory_bytes: 5460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i <= 999; i++) {
    int now = 0;
    bool find = false;
    string str = to_string(i);
    if (10 <= i && i <= 99) {
      str = "0" + str;
    } else if (i < 10) {
      str = "00" + str;
    }
    for (int j = 0; j < N; j++) {
      if (S[j] == str[now]) {
        now++;
      }
      if (now == 3) {
        find = true;
      }
    }
    if (find) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	string s,t;
	cin>>s>>t;
	ll n=s.length();
	ll m=t.length();
	ll dp[n+1][m+1];
	memset(dp,0,sizeof(dp));

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1])
			dp[i][j]=1+dp[i-1][j-1];
			else
			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
	
		}
		//cout<<endl;
	}

 string ans;
 int i=n,j=m;;
  while(i>0&&j>0){
     
      if(s[i-1]==t[j-1]){
      	
      	ans.push_back(t[j-1]);
        i--;
        j--;
        
      }
      else if(dp[i][j-1]>dp[i-1][j]){  j--;    }
      else i--;
 
 }

reverse(ans.begin(), ans.end());
cout<<ans<<endl;
}

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

int main()
{
    char X, Y;
    cin >> X >> Y;

    if (X > Y)
    {
        cout << ">" << endl;
    }
    else if (X < Y)
    {
        cout << "<" << endl;
    }
    else
    {
        cout << "=" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(w_max+1, 0)
items.each do |item|
  wi, vi = item
  tmp = dp.dup
  (wi..w_max).each do |w|
    v = vi + dp[w-wi]
    tmp[w] = v if v > dp[w]
  end
  dp = tmp
end
puts dp.last


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    double perBTC = 380000.0;
    int n; cin>>n;
    double sum = 0.0;
    for (int i = 0; i < n; ++i) {
        double x; string u;
        cin>>x>>u;
        if(u=="JPY"){
            sum+=x;
        }else{
            sum+=x*perBTC;
        }
    }
    cout<<fixed<<setprecision((10))<<sum<<endl;

    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if(n-k == 0){
        cout << 1 << endl;
    }
    else {
        ans = 1 + n-k;
        cout << ans << endl;
    }
    
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, H;
    cin >> N >> H;
    vec B(N);
    ll m = 0;
    REP(i,0,N) {
        ll a;
        cin >> a >> B[i];
        m = MAX(m,a);
    }

    DESC(B);
    REP(i,0,N) {
        if(B[N-i-1] < m) B.pop_back();
        else break;
    }

    ll M = SZ(B), k = 0;
    while(H > 0 && k < M) {
        H -= B[k];
        ++k;   
    }
    if(H > 0) k += (H + m - 1) / m;
    
    PR(k);

    return 0;
}

/*



*/

Measured memory_bytes: 3976
N = input()
a = []
n = len(N)
k = 7

for i in range(len(N)):
    a.append(int(N[i]))

X = [0]*(n-1)
flag = False

for i in range(2**(n-1)):
    if flag:
        break
    S = a[0]
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            X[j] = 1
            S += a[j+1]
        else:
            X[j] = 0
            S -= a[j+1]
    if S == k:
        flag = True
        break
print(a[0], end="")
for i in range(3):
    if X[i] == 1:
        print('+', end='')
    else:
        print('-', end='')
    print(a[i+1], end="")
print('=', end='')
print(k)







Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
char s[N][N];
int n,m;
//vector<int> x[N];
//vector<int> y[N];
int x[N][N];
int y[N][N];


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

    int n,m;
    cin>>n>>m;

    for(int i=1; i<=n; i++)
        cin>>(s[i]+1);


    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            if(s[i][j]=='.')
                y[i][j]=y[i][j-1]+1;
            else
                y[i][j]=0;;
        }
        for(int j=m-1;j>=0;j--)
        {
            if(y[i][j]!=0)
                y[i][j]=max(y[i][j],y[i][j+1]);
        }
    }
    for(int j=1; j<=m; j++)
    {
        for(int i=1; i<=n; i++)
        {
            if(s[i][j]=='.')
                x[i][j]=x[i-1][j]+1;
            else
                x[i][j]=0;;
        }
        for(int i=n-1;i>=0;i--)
        {
            if(x[i][j]!=0)
                x[i][j]=max(x[i+1][j],x[i][j]);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            ans=max(x[i][j]+y[i][j]-1,ans);
    }

    cout<<ans<<endl;
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 35712
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort(reverse=True)
ans = 0
while T:
    t = T.pop()
    ans += 1
    for i in range(C - 1):
        if not T or T[-1] > t + K:
            break
        T.pop()
print(ans)


Measured memory_bytes: 7504
t = int(input())
for _ in range(t):
    n = int(input())
    h = list(map(int, input().split()))
    maxv = minv = 0
    for i in range(len(h)-1):
        maxv = max(maxv, h[i+1]-h[i])
        minv = max(minv, h[i]-h[i+1])
    print(maxv, minv)

Measured memory_bytes: 7572
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    A, B, K = (int(_) for _ in input().split())
    s = set()
    for i in range(A,A+K):
        if i > B:
            break
        s.add(i)
    for i in range(B-K+1,B+1):
        if i < A:
            break
        s.add(i)
    l = list(s)
    l.sort()
    print('\n'.join(str(_) for _ in l))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <iostream>

using namespace std;

typedef int64_t ll;

template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const ll linf = 1LL << 60;

ll N;

int main()
{
	cin >> N;
	ll ans = linf;
	for (ll i = 1; i * i <= N; ++i)
	{
		if (N % i)
			continue;

		ll j = N / i;

		chmin(ans, i + j - 2);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
const int INF=1e9;
bool com(string l,string r){
      if(l.length()!=r.length())return l.length()<r.length();
      REP(i,l.length())if(l[i]!=r[i])return l[i]<r[i];
}
int main(){
      int n;
      map<string,int> M;
      cin>>n;
      vector<string> V;
      REP(i,n){
            string s;int a;
            cin>>s>>a;
            if(M[s]==0)V.PB(s);
            M[s]+=a;
      }
      sort(V.begin(),V.end(),com);
      REP(i,V.size()){
            cout<<V[i]<<" "<<M[V[i]]<<endl;
      }
}

Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int mul(int n,int m,int Matrix[][100],int matrix[][1]);

int main() {
	int Matrix[100][100] = { 0 };
	int matrix[100][1] = { 0 };
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) for (j = 0; j < m; j++) scanf("%d",&Matrix[i][j]);
	for (i = 0; i < m; i++) scanf("%d", &matrix[i][0]);
	for (i = 0; i < n; i++) {
		printf("%d\n", mul(i, m, Matrix, matrix));
	}
	return 0;
}

int mul(int n, int m, int Matrix[][100], int matrix[][1]) {
	int i;
	int sum=0;
	for (i = 0; i < m; i++) {
			sum += Matrix[n][i] * matrix[i][0];
	}
	return sum;
}

Measured memory_bytes: 2776
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

count = 0
for ai in a:
    if ai <= x:
        x -= ai
        count += 1
    else:
        break

# 全員に配り終えても余っている場合は、残りのクッキーを1人にわたす
if count == N and x > 0:
    count -= 1

print(count)


Measured memory_bytes: 3060
def dfs(v):
    visited[v]=True
    for v2 in range(n):
        if graph[v][v2]==False:
            continue
        if visited[v2]==True:
            continue
        dfs(v2)

n,m = map(int,input().split())
visited=[False]*n
graph = []
for i in range(n):
    graph.append([False]*n)
a=[]
b=[]
for i in range(m):
    aa,bb = map(int,input().split())
    a.append(aa-1)
    b.append(bb-1)
for i in range(m):
    graph[a[i]][b[i]] = True
    graph[b[i]][a[i]] = True
ans = 0
for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    for j in range(n):
        visited[j]=False
    dfs(0)
    bridge=False
    for j in range(n):
        if visited[j]==False:
            bridge =True
    if bridge:
        ans += 1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True
print(ans)


Measured memory_bytes: 3064
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include<iostream>
using namespace std;
int min(int x, int y)
{
    return x > y ? y : x;
}

/*
dp(i, j) 定义：字符串s1 0到i 与 字符串s2 0到j 之间的距离
也就是：s1(0, i) s2(0, j)之间的距离
*/
int minDistance(char* word1, char* word2) {
    int l1 = strlen(word1);
    int l2 = strlen(word2);

    if (l1 == 0 && l2 == 0) {
        return 0;
    }

    //初始化
    int dp[l1+1][l2+1];
    for(int i=0; i<=l1; ++i){
        for(int j=0; j<=l2; ++j){
            dp[i][j] = 0;
        }
    }

    //一直删除，需要l1步
    for(int i=0; i<= l1; ++i){
        dp[i][0] = i;
        //printf("%d %d -> %d\n", i, 0, dp[i][0]);
    }

    //一直增加，需要l2步
    for(int j=0; j<=l2; ++j){
        dp[0][j] = j;
        //printf("%d %d -> %d\n", 0, j, dp[0][j]);
    }
//自底向上
    for(int i=1; i<= l1; ++i){
        for(int j=1; j<= l2; ++j){
            //置换
            int replace = word1[i-1] == word2[j-1] ? dp[i - 1][j - 1] : dp[i - 1][j - 1] + 1;
            int ins_del = min(dp[i][j - 1] + 1, dp[i - 1][j] + 1);
            dp[i][j] = min(replace, ins_del);
        }
    }
    return dp[l1][l2];
}

int main()
{
    char s[2010],c[2010];
    cin>>s>>c;
    printf("%d\n", minDistance(s, c));
    return 0;
}




Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

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

    ll ans = 0;
    for(int i = 1;i < n+1;++i){
        if(i % 3 != 0 && i % 5 != 0){
            ans += (ll)i;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int cmp(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){

  int N,K;
  cin >> N >> K;
  int p[N];
  rep(i,N) cin >> p[i];
  qsort(p,N,sizeof(int),cmp);
  
  int ans=0;
  rep(i,K) ans += p[i];
  
  cout << ans;
  
  
  return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 a, b, c;
  cin >> a >> b >> c;

  if ((a != b && b == c) || (b != c && c == a) || (c != a && a == b)) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 1e5 + 9, M = 50 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(12);
//	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

int n;
ll heros[N], monsters1[N], monsters2[N], ans, a, b, c, d, e, f;
int main() {
//	INPUT();
	OUTPUT();
	cin >> n;
	for (int i = 0; i <= n; ++i) {
		cin >> monsters1[i];
		monsters2[i] = monsters1[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> heros[i];
	}
	for (int i = 0; i < n; i++) {
		a = min(monsters1[i], heros[i]);
		b = min(monsters1[i + 1], max((ll) 0, heros[i] - a));
		monsters1[i + 1] -= b;
		c += (a + b);
	}
	for (int i = 0; i < n; i++) {
		d = min(monsters2[i + 1], heros[i]);
		monsters2[i + 1] -= d;
		e = min(monsters2[i], max((ll) 0, heros[i] - d));
		f += (e + d);
	}
	cout << max(c, f);

	return 0;

}


Measured memory_bytes: 2688
from itertools import product

H, W, M = map(int, input().split())

HL = [0]*H
WL = [0]*W
B = []

for _ in range(M):
  h, w = map(int, input().split())
  B.append((h, w))
  HL[h-1] += 1
  WL[w-1] += 1

HM = max(HL)
WM = max(WL)

H_ans = [0]*H
W_ans = [0]*W

for i in range(H):
  if HL[i] == HM:
    H_ans[i] += 1

for j in range(W):
  if WL[j] == WM:
    W_ans[j] += 1

if sum(H_ans)*sum(W_ans) > M:
  print(HM+WM)
else:
  cnt = 0
  for h, w in B:
    if H_ans[h-1] + W_ans[w-1] == 2:
      cnt += 1
  if sum(H_ans)*sum(W_ans) > cnt:
    print(HM+WM)
  else:
    print(HM+WM-1)

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar (char ch)
{
	if (ch=='A') return 1;
	else if (ch=='C') return 2;
	else if (ch=='G') return 3;
	else if (ch=='T') return 4;
	else return 0;
}

long long getKey(char str[])
{
	long long sum=0,p=1,i;
	for (i=0;i<strlen(str);i++)
	{
		sum+=p*(getChar(str[i]));
		p*=6;
	}
	return sum;
} 

int h1(int key)
{
	return key%M;
}

int h2(int key)
{
	return 1+(key%(M-1));
}

int find (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0) return 0;
	} 
	return 0;
}

int insert (char str[])
{
	long long key,i,h;
	key=getKey(str);
	for (i=0;;i++)
	{
		h=(h1(key)+i*h2(key))%M;
		if (strcmp(H[h],str)==0) return 1;
		else if (strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
}
int main ()
{
	int i,n,h;
	char str[L],com[9];
	for (i=0;i<M;i++) H[i][0]='\0';
	scanf ("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf ("%s %s",com,str);
		if (com[0]=='i')
		{
			insert(str);
		}
		else {
			if (find(str)) printf ("yes\n");
			else printf ("no\n");
		}
	}
	return 0;
}


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

int main() {
  int a, a_100, a_10, a_1;
  cin >> a;
  a_100 = a / 100;
  a_10 = (a - a_100 * 100) / 10;
  a_1 = (a - a_100 * 100 - a_10 * 10) / 1;
  cout << a_100 + a_10 + a_1 << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define f first
#define s second
#define endl "\n"
#define M 1000000007
#define pb push_back
#define pf push_front
#define eb emplace_back
#define MM_PI 3.14159265358979323846
#define TEST_CASE int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T pow(T a, T b, long long m) {T ans = 1; while (b > 0) { if (b % 2 == 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans % m; }

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

const int maxn = 1e5 + 10;

void solve() {
	ll n, k;
	cin >> n >> k;
	ll w[n + 10], val[n + 10];
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> val[i];
	}
	ll total = 0;
	for (int i = 0; i < n; i++) {
		total += val[i];
	}
	ll dp[n + 10][total + 10];
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= total; j++) {
			dp[i][j] = 1e14;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= total; j++) {
			if (val[i] <= j) {
				dp[i + 1][j] = min(w[i] + dp[i][j - val[i]], dp[i][j]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0 ;

	for (int j = 0; j <= total; j++) {
		if (dp[n][j] <= k)ans = j;
	}

	cout << ans << endl;

}
int main() {

	//IOS
	//make();
	//TEST_CASE
	solve();
	return 0;
}



Measured memory_bytes: 79744
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int count[300] = { 0 };
	string s;
	int i;
	cin >> s;
	for (i = 0; i < 4; i++) {
		count[s[i]]++;
	}
	sort(count, count + 300);

	if (count[299] == 2 && count[298] == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

 using namespace std;
  vector<int> G[101];
  bool V[101];
  bool Vis[101];
  int DP[101];
   int N;
   int Ans = 0;
   int P;
  void DFS(int n,int len){
      Ans = (Ans<=len)? len : Ans;
      DP[n] = (DP[n]<=len)? len : DP[n];
      if(DP[n]==Ans) P = n;
      int S = G[n].size();
      for(int i=0;i<S;i++){
    if(!V[G[n][i]]){
        Vis[G[n][i]]= true;
        V[G[n][i]] = true;
        DFS(G[n][i],len+1);
        V[G[n][i]] = false;
    }
   }
   return;
  }
  int i;
  int main(){
      do{

   for(i=0;i<101;i++){
    G[i].clear();
    V[i] = false;
   Vis[i] = false;
    DP[i] = 0;
   }
   Ans = 0;
   scanf("%d",&N);
   if(N==0)break;
   for(i=0;i<N;i++){
    int A,B;
    scanf("%d%d",&A,&B);
    G[A].push_back(B);
    G[B].push_back(A);
   }

   for(i=1;i<=100;i++){
    if(!Vis[i]){
    Vis[i] =true;
    V[i] = true;
    DFS(i,1);
    V[i] = false;
    }
   }
  if(DP[P]==Ans){
        V[P] = true;
        DFS(P,1);
   }
   printf("%d\n",Ans);
  }while(true);
  }

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector< ii > vii;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef	vector<pair<int,pair<int,int > > > viii;
typedef long long int lli;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define slli(n) scanf("%llid",&n)
#define lldout(n) printf("%llid\n",n)
const int N = (int)1e5 + 10;
//vvi v;
vector<vector<lli> > v;
lli cnt=0;
lli vis[N];
//int vis1[52][52],v[52][52];
int dfs(int t,int p){
	vis[t]=1;
  cnt++;
	//v[i][j]=val;
	rep(i,0,v[t].size()){
    if(v[t][i]==p){return 0;}
		if(vis[v[t][i]]==0){
			dfs(v[t][i],p);
		}
	}
	// if(v[i][j-1]==-1 and vis1[i][j-1]==0 and v[i+1][j-1]!=v[i][j] and v[i][j-2]!=v[i][j] and v[i-1][j-1]!=v[i][j])dfs(i,j-1,val);
	// if(v[i][j+1]==-1 and vis1[i][j+1]==0 and v[i][j+2]!=v[i][j] and v[i+1][j+1]!=v[i][j] and v[i-1][j+1]!=v[i][j])dfs(i,j+1,val);
	// if(v[i-1][j]==-1 and vis1[i-1][j]==0 and v[i-1][j-1]!=v[i][j] and v[i-1][j+1]!=v[i][j] and v[i-2][j]!=v[i][j])dfs(i-1,j,val);
	// if(v[i+1][j]==-1 and vis1[i+1][j]==0 and v[i+2][j]!=v[i][j] and v[i+1][j-1]!=v[i][j] and v[i+1][j+1]!=v[i][j])dfs(i+1,j,val);
	// return 0;
}
lli lcm(lli a,lli b) { return a*(b/__gcd(a,b));}
lli pow(lli x, lli y, lli p) {
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
map<lli,lli> ph;
lli vis1[200005],vis2[200005];
int main(){
  vector<int> v1;
	rep(i,0,3){
		int x;
		cin>>x;
		v1.pb(x);
	}
	sort(v1.begin(),v1.end());
	cout<<v1[1]-v1[0] + v1[2]-v1[1] <<endl;
  return 0;
}


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

#define ll long long
#define ii pair<int,int>

using namespace std;

int n,m;
vector<ii>adj[20][20];
int bfs(ii start, ii end){
	int dist[n][m];
	for(int i = 0;i <n;i++){
		for(int j = 0;j < m;j++){
			dist[i][j] = -1;
		}
	}
	queue<ii>qu;
	qu.push(start);
	dist[start.first][start.second] = 0;
	while(!qu.empty()){
		ii u = qu.front();
		qu.pop();
		if(u == end) break;
		for(auto i: adj[u.first][u.second]){
			if(dist[i.first][i.second] == -1){
				qu.push(i);
				dist[i.first][i.second] = dist[u.first][u.second] +1;
			}
		}
	}
	return dist[end.first][end.second];
}


int main(){
	cin >> n >>m;
	vector<string>a(n);
	for(int i =0 ;i <n;i++) cin >> a[i];
	for(int i = 0;i <n;i++){
		for(int j = 0;j < m;j++){
			if(i > 0 && a[i-1][j] != '#'){
				adj[i][j].push_back(ii(i-1,j));
			}
			if(j > 0 && a[i][j-1] != '#'){
				adj[i][j].push_back(ii(i,j-1));
			}
			if(i < n-1 && a[i+1][j] != '#'){
				adj[i][j].push_back(ii(i+1,j));
			}
			if(j < m-1 && a[i][j+1] != '#'){
				adj[i][j].push_back(ii(i,j+1));
			}
		}
	}
	vector<ii>pos = {ii(0,0),ii(0,m-1),ii(n-1,0),ii(n-1,m-1)};
	int ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(a[i][j] == '#') continue;
			for(int k = 0;k <n;k++){
				for(int l = 0;l < m;l++){
					if(a[k][l] == '#')continue;
					ans = max(ans,bfs(ii(i,j),ii(k,l)));
				}
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int f = 1;
  	for (int i = 0; i < N; i++){
      if (f <= K){
        f = f*2;
      	continue;
      }
      else{
        f = f + K;
        continue;
      }
	}
	cout << f << endl;
}

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

const int maxn = 1e5+5;
int n, a[maxn], b[maxn];

ll ans[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    vector<pair<int,int>> v;
    for (int i = 0; i < n; i++) {
        if (v.empty() || a[i] > v.back().first) {
            v.push_back({a[i],i});
        }
    }
    sort(a,a+n,greater<int>());
    reverse(v.begin(),v.end());
    v.push_back({0,n});
    int pt = 0;
    for (int i = 0; i < v.size()-1; i++) {
        int val = v[i].first;
        int idx = v[i].second;
        while (pt < n && a[pt] > v[i+1].first) {
            while (pt < n && a[pt] >= val) pt++;
            ans[idx+1] += 1LL*pt*(val-a[pt]);
            val = a[pt];
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;

    /*
    map<int,int> ac;
    while (true) {
        map<int,vector<int>> mp;
        for (int i = 0; i < n; i++) {
            mp[b[i]].push_back(i);
        }
        auto p = *mp.rbegin();
        ac[p.second[0]+1]++;
        b[p.second.back()]--;
        bool cont = false;
        for (int i = 0; i < n; i++) {
            if (b[i] > 0) cont = true;
        }
        if (!cont) break;
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ' << ac[i] << endl;
        assert(ans[i] == ac[i]);
    }
    */
}



Measured memory_bytes: 3572
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int n,t,a;
  cin >> n;
  cin >> t >> a;
  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int ans =0;
  double diff = 100000;

  for (int i = 0; i < n; i++) {
    double tmp = t - h[i]*0.006;
    if (abs(tmp-a)< diff) {
      diff = abs(tmp-a);
      ans = i+1;
    }
  }
  cout << ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}

const int maxN = 103;

int n, m, col;
int a[maxN][maxN];

vector< pair<int, int> > adj[maxN];
int le[maxN], ri[maxN];
bool used[maxN];

bool pairUp(int node) {
    if (used[node]) return false;
    used[node] = true;

    for (auto to: adj[node]) {
        if (ri[to.first] == 0) {
            le[node] = to.first;
            ri[to.first] = node;
            return true;
        }
    }

    for (auto to: adj[node]) {
        if (pairUp(ri[to.first])) {
            le[node] = to.first;
            ri[to.first] = node;
            return true;
        }
    }

    return false;
}

int findEdge(int node, int dest) {
    for (int i = 0; i < adj[node].size(); i++) {
        auto to = adj[node][i];

        if (to.first == dest) {
            adj[node][i] = adj[node].back();
            adj[node].pop_back();
            return to.second;
        }
    }

    cerr << "Error";
    exit(-1);
}

void findColumn() {
    memset(le, 0, sizeof(le));
    memset(ri, 0, sizeof(ri));

    bool need = true;
    while (need) {
        need = false;
        memset(used, 0, sizeof(used));
    
        for (int i = 1; i <= n; i++)
            if (!le[i])
                need |= pairUp(i);
    }

    col++;
    for (int i = 1; i <= n; i++) 
        a[col][i] = findEdge(i, le[i]);
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &a[i][j]);
            int to = (a[i][j] - 1) / m + 1;
            adj[i].pb(mp(to, a[i][j]));
        }
    }

    for (int times = 1; times <= m; times++) 
        findColumn();

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d ", a[j][i]);
        }
        printf("\n");
    }

    for (int i = 1; i <= m; i++)
        sort(a[i] + 1, a[i] + n + 1);

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            printf("%d ", a[j][i]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    x1, y1, x2, y2 = map(int, input().split())
    x = x2 - x1
    y = y2 - y1
    print(x2 - y, y2 + x, x1 - y , y1 + x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    while b :
        a, b = b, a % b
    return a

L = [0] * (N+1)
R = [0] * (N+2)

for i in range(N):
    L[i+1] = gcd(L[i],A[i])
for i in range(N)[::-1]:
    R[i+1] = gcd(R[i+2],A[i])
    
ans = 0

for i in range(1,N+1):
    ans = max(ans, gcd(L[i-1], R[i+1]))

print(ans)

Measured memory_bytes: 14584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int i;
	
		int n=sc.nextInt();
		int a[] = new int[n];
		
		for(i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		
		for(i=n-1; i>=0; i--) {
			if(i>0) System.out.printf("%s ", a[i]);
			else System.out.printf("%d", a[i]);
		}
		
		System.out.printf("\n");
		
	}
}



Measured memory_bytes: 26492
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
char a;
int main(){
	a=getchar();
	bool f;
	switch(a){
		case 'a':f=true;break;
		case 'e':f=true;break;
		case 'i':f=true;break;
		case 'o':f=true;break;
		case 'u':f=true;break;
		default:f=false;
	}
	if(f) puts("vowel");
	else puts("consonant");
	exit(0);
} 

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

int main()
{
    int n;
    cin >> n;
    int wa=0;
    vector<int> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t.at(i);
        wa+=t.at(i);
    }
    int m;
    cin >> m;
    vector<int> p(m);
    vector<int> x(m);
    for (int i = 0; i < m; i++)
    {
        cin >> p.at(i) >> x.at(i);
        wa-=t.at(p.at(i)-1);
        wa+=x.at(i);
        cout<<wa<<endl;
        wa-=x.at(i);
        wa+=t.at(p.at(i)-1);
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


int main() {
  int n; cin >> n;
  vi a(n,0);
  int ans = 0;
  int kudaki = 0;
  int now = 0;
  rep(i,n) {
    int t;cin >> t;
    a.at(i) = t-1;
  }

  int osiri = 0;
  rep(i,n) {
    if(a.at(i) == now) {
      ans += kudaki;
      kudaki = 0;
      now++;
      osiri = i;
      continue;
    }
    kudaki++;
  }

  if(n-1 > osiri) ans += n - osiri - 1;

  if(now > 0) cout << ans << endl;
  else cout << -1 << endl;


  return 0;
}


Measured memory_bytes: 4024
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n;
	int d, min, max;
	long long sum;

	scanf("%d%d", &n, &d);
	sum = min = max = d;
	while (--n > 0) {
		scanf("%d", &d);
		if (d < min) min = d;
		if (d > max) max = d;
		sum += d;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2100
/*
Aldew
PROB: Save Konoha
CLASSIFICATION: Priority Queue
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#include <stack>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

vector <int> factors(int x) {
    vector <int> result;
    int i = 1;
    while(i*i <= x) {
        if(x % i == 0) {
            result.push_back(i);
            if(x/i != i) {
                result.push_back(x/i);
            }
        }
        i++;
    }
    return result;
}

int main()
{
    io;
    char c;
    cin >> c;

    if (isupper(c)){
        cout << 'A' << endl;
    }
    else {
        cout << 'a' << endl;
    }
  return 0;
}


Measured memory_bytes: 3648