akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define XOX
using namespace std;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int p1=a*c;
    int p2=b*d;
    int p3=a*d;
    int p4=b*c;
    cout<<max(p1,max(p2,max(p3,p4)))<<"\n";
    return 0;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int ans = 1e9;
  for (int bit = 0; bit < 1 << N; bit++) {
    vector<int> tmp(M);
    int tmp2 = 0;
    for (int i = 0; i < N; i++) {
      if (bit >> i & 1) {
        tmp2 += C.at(i);
        for (int j = 0; j < M; j++) {
          tmp.at(j) += A.at(i).at(j);
        }
      }
    }
    int mi = *min_element(tmp.begin(), tmp.end());
    if (mi >= X) ans = min(ans, tmp2);
  }
  cout << ((ans == 1e9) ? -1 : ans) << "\n";
}

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

const int MOD = 1000000007;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


int main(){
  long long int n,k,i,j,kari,kotae=0;
  cin>>n>>k;
  long long int a[k+1];
  for(i=0;i<=k;i++){
    a[i]=0;
  }
  for(i=k;i>=1;i--){
    j=k/i;
    if(j==1){
      a[i]=1;
    }else{
      kari=modpow(j,n);
      for(;j>=2;j--){
        kari=(kari+MOD-a[i*j])%MOD;
      }
      a[i]=kari;
    }
    kotae=(kotae+a[i]*i)%MOD;
  }
  cout<<kotae;
}
  

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

int main()
{
    int n, Y, x = 0, y = 0, z = 0;
    cin>>n>>Y;
    while(Y >= 10000)
    {
        Y -= 10000;
        x++;
    }
    while(Y >= 5000)
    {
        Y -= 5000;
        y++;
    }
    while(Y >= 1000)
    {
        Y -= 1000;
        z++;
    }
    int diff = n - (x + y + z);
    //cout<<diff<<endl;
    while(diff > 0)
    {
        if(x > 0 && diff >= 9)
        {
            diff -= 9;
            x--;
            z += 10;
        }
        else if(y > 0 && diff >= 4)
        {
            diff -= 4;
            y--;
            z += 5;
        }
        else if(x > 0 && diff >= 1)
        {
            diff -= 1;
            x--;
            y += 2;
        }
        else if(diff > 0)
        {
            cout<<"-1 -1 -1";
            return 0;
        }
    }
    if(x + y + z == n)
        cout<<x<<" "<<y<<" "<<z;
    else
        cout<<"-1 -1 -1";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, mod = 1e9 + 7;
int s, fac[N], ifac[N];
int fpw(int a, int b)
{
	int ans = 1;
	while(b)
	{
		if(b&1) ans = 1ll*ans*a%mod;
		a = 1ll*a*a%mod;
		b >>= 1;
	}
	return ans;
}
void init(int n)
{
	fac[0] = 1;
	for(int i=1; i<=n; i++) fac[i] = 1ll*fac[i-1]*i%mod;
	ifac[n] = fpw(fac[n], mod-2);
	for(int i=n-1; i>=0; i--) ifac[i] = 1ll*ifac[i+1]*(i+1)%mod;
}
int comb(int n, int m)
{
	if(n<m||n<0||m<0) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> s;
	init(s);
	int ans = 0;
	for(int i=1; i<=s/3; i++) ans = (ans + comb(s-2*i-1, i-1))%mod;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3632
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if diff == d and j % 2 == 0:
        flag == True
        break
    if j == 0:
        break

    k = abs(diff - d) / j
    if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):
        flag = True
        break
    k = abs(diff + d) / j
    if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")



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

using namespace std;

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

    int ans = 0;

    
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            for (int k = 1;  k <= n; ++k)
                ans += __gcd(i, __gcd(j,k));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 

int main(void) {
  ll n;cin>>n;
  vector<pair<int, int>> rl(n);
  fr(i,n) {
    int x, l;
    cin >> x >> l;
    rl[i].first = x+l;
    rl[i].second = x-l;
  }
  sort(rl.begin(), rl.end());
  int c = -1e9;
  int ans = 0;
  fr(i, n){
    if(c<=rl[i].second) c = rl[i].first, ans++;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int GCD(int x,int y){
  int r;
  if(x==y){
    r=x;
  }else{
    while(x%y!=0){
      r=x%y;
      x=y;
      y=r;
    }
  }
  return r;
}

int main(void){
  int x,y,temp;

  scanf("%d %d",&x,&y);

  if(x<y){
    temp=x;
    x=y;
    y=temp;
  }

  printf("%d\n",GCD(x,y));

  return 0;
}

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

using namespace std;

#define ll long long
int MAX=80;

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

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    ll a[MAX];
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}	
    ll money=1000;
    int start=0;
    ll stocks;
    for(int i=0;i<n-1;i++){
    	if(a[i+1]>a[i])
    		continue;
    	else{
    		stocks=money/a[start];
    		money=(money-(stocks*a[start]))+(stocks*a[i]);
    		start=i+1;
		}
	}
	if(start!=n-1){
		stocks=money/a[start];
		money=(money-(stocks*a[start]))+(stocks*a[n-1]);
	}
	cout<<money;
	
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace __gnu_pbds;
using namespace std;

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;
int a[30];
int b[30];
int c[30];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n+1) cin >> a[i];
    rep(i, 1, n+1) cin >> b[i];
    rep(i, 1, n+1) cin >> c[i];
    rep(i, 1, n+1) {
        ans += b[a[i]];
        if (i > 1 && a[i] == a[i-1]+1) ans += c[a[i-1]];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int main(void){
    int w;
    char s[1005];
    cin>>s>>w;
    int n=strlen(s);
    for(int i=0;i<n;i+=w){
        cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	
	cin >> n;
	if (n >= 1000)
	{
		cout << "ABD" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}
	

		
	

	
	
}
	

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
pair<string, int>X[1000];
vector<int>Y[1000];
int dp[1000];
int N, M, C, Q; string S;
int main() {
	while (true) {
		for (int i = 0; i < 1000; i++) {
			dp[i] = 0;
			Y[i].clear();
			X[i] = make_pair("", 0);
		}
		cin >> N;
		if (N == 0) { break; }
		for (int i = 0; i < N; i++) {
			cin >> X[i].first >> X[i].second;
			dp[i] = X[i].second;
		}
		cin >> M;
		for (int i = 0; i < M; i++) {
			cin >> S;
			for (int j = 0; j < N; j++) {
				if (S == X[j].first) {
					C = j;
				}
			}
			cin >> Q;
			for (int j = 0; j < Q; j++) {
				cin >> S;
				for (int k = 0; k < N; k++) {
					if (X[k].first == S) {
						Y[C].push_back(k);
					}
				}
			}
		}
		for (int i = 0; i < N * 2; i++) {
			for (int j = 0; j < N; j++) {
				int sum = 0;
				if(Y[j].size()==0){
					continue;
				}
				for (int k = 0; k < Y[j].size(); k++) {
					sum += dp[Y[j][k]];
				}
				if (dp[j] > sum) {
					dp[j] = sum;
				}
			}
		}
		cin >> S;
		for (int i = 0; i < N; i++) {
			if (S == X[i].first) {
				C = i;
			}
		}
		cout << dp[C] << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s[] = sc.next().split("",0);
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int c = Integer.parseInt(s[2]);
        int d = Integer.parseInt(s[3]);
        if(a+b+c+d==7) System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
        else if(a-b+c+d==7) System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
        else if(a+b-c+d==7) System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
        else if(a-b-c+d==7) System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
        else if(a+b+c-d==7) System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
        else if(a-b+c-d==7) System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
        else if(a+b-c-d==7) System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
        else if(a-b-c-d==7) System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
    }
    
}

Measured memory_bytes: 21588
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
//#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n;
    cin >> n;

    vector<string> s(n);

    int maxv = 0;
    map<string,int> mp;
    rep(i,n){
        cin >> s[i];
        mp[s[i]]++;
        chmax(maxv,mp[s[i]]);
    }

    sort(all(s));
    map<string,bool> flg;

    rep(i,n){
        if(mp[s[i]] == maxv && !flg[s[i]]){
            cout << s[i] << '\n';
            flg[s[i]] = true;
        }
    }


    return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(20);

  ll n, k; cin >> n >> k;
  ld ans = 0;

  rep2(i, 1, n) {
    ll score = i;
    ld p = 1;

    while (score < k) {
      score *= 2;
      p /= 2.0;
    }

    ans += p;
  }

  cout << ans / n << endl;
}


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

int main(){

  int n,d,p;
  cin >> n >> d;

  int sum=0;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p-d>0)sum+=p-d;
  }

  if(sum>0)cout << sum << endl;
  else cout << "kusoge\n";


  return 0;
}



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

int main() {
    int a,b,d,r;
    double f;
    cin>>a>>b;
    d = a / b;
    r = a % b;
    f = (double)a / b;
    cout<<d<<" "<<r<<" ";
    cout<<fixed<<setprecision(5)<<f<<endl;
    return 0;
}


Measured memory_bytes: 3284
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
ll rec (ll x) {
	if (x == 1) {
		return 1;
	}
	return rec (x / 2) * 2 + 1;
}
void solve () {
	ll x;
	cin >> x;
	cout << rec (x);	
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

using namespace std;

void solve(int d, int e) {
    double ans = 114514;
    for(int x=0; x<=d; ++x) {
        ans = min(ans, abs(sqrt(x*x + (d-x)*(d-x)) - e));
    }
    printf("%.5lf\n", ans);
}

int main() {
    int d,e;
    while(cin>>d>>e && d) solve(d,e);
    return 0;
}

Measured memory_bytes: 3080
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int H, W, N;
int mk(int r, int c) {
	return r*W+c;
}

bool check(vector<int>places,const vector<vector<int>>&tos, int time) {
	
	for (int i = 0; i < 20; ++i) {
		if (time&(1 << i)) {
			for (auto&pl : places) {
				pl=tos[pl][i];
			}
		}
	}
	sort(places.begin(),places.end());
	if(unique(places.begin(),places.end())==places.end())return false;
	else return true;
}

int main() {
	cin>>H>>W>>N;
	vector<vector<int>>tos(H*W,vector<int>(20));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int r,c;cin>>r>>c;
			tos[mk(i,j)][0]=mk(r,c);
		}
	}
	for (int k = 1; k < 20; ++k) {
		for (int i = 0; i < H*W; ++i) {
			tos[i][k]=tos[tos[i][k-1]][k-1];
		}
	}
	vector<int>starts(N);
	for (int i = 0; i < N; ++i) {
		int r,c;cin>>r>>c;
		starts[i]=mk(r,c);
	}
	int amin=0;
	int amax=H*W+1;
	while (amin + 1 != amax) {
		int amid=(amin+amax)/2;
		if (check(starts, tos, amid)) {
			amax=amid;
		}
		else {
			amin=amid;
		}
	}
	if(amax==H*W+1)amax=-1;
	cout<<amax<<endl;
	return 0;
}


Measured memory_bytes: 34060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 1000000;
ll mod = INF;

int main(){
    string s;
    cin >> s;
    int n=s.size();
    if(s[n-1]=='e'){
        cout << s+'s'<<endl;
    }else if(s[n-1]=='s'){
        cout << s+"es"<<endl;
    }else{
        cout << s+"s"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3600
function main()
  V=zeros(Int,3010,3010)
  dp=zeros(Int,3010,3010,4)
  R,C,K=parse.(Int,split(readline()))
  for i=1:K
    r,c,v=parse.(Int,split(readline()))
    V[r,c]=v
  end
  for i=1:R
    for j=1:C
      for k=1:3
        @inbounds dp[i+1,j+1,k+1]=max(max(dp[i,j+1,4],dp[i+1,j,k])+V[i,j],dp[i+1,j,k+1])
      end
    end
  end
  println(dp[R+1,C+1,4])
end
main()

Measured memory_bytes: 571936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main() {
    ll n,m;
    cin >> n >> m;
    UnionFind tree(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        tree.unite(a,b);
    }
    ll cnt=0;
    for(ll i=0;i<n;i++){
        if(!tree.same(0,i)){
            tree.unite(0,i);
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4060
/*  Name: Abu Hurayra
    Handle: HurayraIIT
    Institute: IIT_JU   */

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef string S;
typedef double D;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;

#define pi acos(-1.0)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define Fin freopen("input.txt","r",stdin)
#define Fout freopen("output.txt","w",stdout)

int main()
{
	off;
    
    int a,b;
    cin >> a >> b;
    
    cout << max(max(a+b,a-b),a*b) << endl;

    


	return 0;

}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll f(ll n){
    ll m=1;
    rep(i,n+1)m*=2;
    return m-1;
}

int main(){
    ll h;
    cin>>h;
    ll ans;
    ll cnt=0;
    while(h>1){
        cnt++;
        h/=2;
    }
    cout<<f(cnt);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < input.length; i++) {
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		for (int i = 0; i < input.length; i++) {
			if (x > input[i]) {
				if (i == N - 1) {
					System.out.println(i);
					System.exit(0);
				}
				x -= input[i];
				continue;
			}
			if (x == input[i]) {
				System.out.println(i + 1);
				break;
			}
			if (x < input[i]) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 36184
#!/usr/bin/env python3

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
#print(A)

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


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

print(max(dp[N][0], max(dp[N][1], dp[N][2])))


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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

using ll  = long long int;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;

const int inf = (1<<28);
const ll infl = (1LL<<60);
const int mod = 1e9+7;

int main() {
    string s; cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
double a,b,c,d,e,f,x,y;
while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
 y=(c*d-f*a)/(b*d-e*a);
 x=(c-b*y)/a;
 printf("%.3f %.3f\n",x,y);
 }
return 0;}

Measured memory_bytes: 652
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
#define debug(x) std::cout << #x << ": " << x << endl
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif

    int r;
    cin >> r;
    cout << r * r;

    return 0;
}




Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[100001],marr[100001];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }

    int j=n/2-1,cnt=0;
    for(int i=n-1; i>=0; i--,j--)
    {

            if(cnt==(n/2))
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        if(s[j]==s[i])
        {

            cnt++;
        }
        else
            break;
    }
    cout<<"No"<<endl;
}


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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] r = new int[n];

		for(int i = 0; i < n; i++){
			r[i] = Integer.parseInt(br.readLine());
		}

		int min = r[0];
		int max = Integer.MIN_VALUE;

		for(int i = 1; i < n; i++){
			max = Math.max(max, r[i] - min);
			min = Math.min(min, r[i]);
		}

		System.out.println(max);

	}

}

Measured memory_bytes: 42840
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 500010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, q;
string s;
int t[26][MAXN];

void update(int cs, int u, int gt) {
    while (u <= 500000) {
        t[cs][u] += gt;
        u = u + (u & (-u));
    }
}

int get(int cs, int u) {
    int res = 0;
    while (u) {
        res += t[cs][u];
        u = u - (u & (-u));
    }
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> s >> q;
    s = " " + s;
    FOR(i,1,n) update(s[i]-'a', i, 1);
    while (q--) {
        int ch;
        cin >> ch;
        if (ch == 1) {
            int u; char v;
            cin >> u >> v;
            int old = s[u] - 'a';
            update(old, u, -1);
            int ne = v - 'a';
            update(ne, u, 1);
            s[u] = char(v);
        }
        else {
            int u, v;
            cin >> u >> v;
            int cnt = 0;
            FOR(i,0,25)
                if (get(i, v) - get(i, u-1)) cnt++;
            cout << cnt << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 51760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    string s;
    cin >> n >> k >> s;

    vl v0, v1;
    if(s[0] == '0') {
        v1.pb(0);
    }
    ll cnt0 = 0, cnt1 = 0;
    rep(i, n) {
        if(i > 0 && s[i-1] == '0' && s[i] == '1') {
            v0.pb(cnt0);
            cnt0 = 0;
        }
        else if(i > 0 && s[i-1] == '1' && s[i] == '0') {
            v1.pb(cnt1);
            cnt1 = 0;
        }
        if(s[i] == '0') {
            cnt0++;
        }
        else {
            cnt1++;
        }
    }
    if(s[n-1] == '0') {
        v0.pb(cnt0);
        v1.pb(0);
    }
    else {
        v1.pb(cnt1);
    }

    if(k >= v0.size()) {
        out(n);
        re0;
    }

    ll m = v0.size();
    vl rui0(m+1);  // rui0[i+1] : v0[i]までの和
    vl rui1(m+2);  // rui1[i+1] : v1[i]までの和
    rep(i, m) { 
        rui0[i+1] = rui0[i] + v0[i];
    }
    rep(i, m+1) {
        rui1[i+1] = rui1[i] + v1[i];
    }

    ll ans = 1;
    rep(i, m-k+1) {
        chmax(ans, (rui1[i+k+1] - rui1[i]) + (rui0[i+k] - rui0[i]));
    }

    out(ans);
    re0;
}

Measured memory_bytes: 2164
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n != 0) {
            int kosu[] = new int[10];

            // kosu[0] ... アイス0の売り上げ数
            // kosu[1] ... アイス1の売り上げ数
            //  :
            // kosu[9] ... アイス9の売り上げ数
            for (int i = 0; i < n; ++i) {
                int ico = scanner.nextInt();
                kosu[ico]++;
            }
            for (int i = 0; i < 10; ++i) {
                if (kosu[i] == 0) {
                    System.out.println("-");
                } else {
                    for (int j = 0; j < kosu[i]; ++j) {
                        System.out.print("*");
                    }
                    System.out.println("");
                }

            }
            n = scanner.nextInt();
        }
    }
}



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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;

int n, a[3005];

ll dp[2][3005][3005];
ll go2(int i, int j);
ll go1(int i, int j){
    //error(i,j);
    if(dp[0][i][j]!=-1){
        return dp[0][i][j];
    }
    if(i>j)
        return 0;
    return dp[0][i][j] = max(a[i]+go2(i+1,j),a[j]+go2(i,j-1));
}
ll go2(int i, int j){
    //error(i,j);
    if(dp[1][i][j]!=-1){
        return dp[1][i][j];
    }
    if(i>j)
        return 0;
    return dp[1][i][j] = min(go1(i+1,j)-a[i],go1(i,j-1)-a[j]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i = 0; i<n; ++i)
        cin>>a[i];
    cout<<go1(0,n-1)<<"\n";
    return 0;
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

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

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

lint stl(char x){
    return (lint)(x - 'a');
}


int main(){
    lint mod = 1e9+7;
    STR(s); int n = Size(s);
    vlint a(n+1, 0), c(n+1, 0), ql(n+1, 0), qr(n+1, 0);
    vlint Exp(n+1, 1);
    rep(i, n){
        if (s[i] == 'A') a[i] ++;
        if (s[i] == '?') ql[i] ++;
        a[i+1] += a[i]; a[i+1] %= mod;
        ql[i+1] += ql[i]; ql[i+1] %= mod;
        Exp[i+1] = Exp[i] * 3 % mod;
    }
    for (int i = n-1; i > 0; i--){
        if (s[i] == 'C') c[i] ++;
        if (s[i] == '?') qr[i] ++;
        c[i-1] += c[i]; c[i-1] %= mod;
        qr[i-1] += qr[i]; qr[i-1] %= mod;
    }

    lint ans = 0;
    rep1(i, n-1){
        if (s[i] == 'B' || s[i] == '?'){
            ans += a[i-1] * c[i+1] % mod * Exp[ql[i-1] + qr[i+1]] % mod; ans %= mod;
            ans += ql[i-1] * c[i+1] % mod * Exp[ql[i-1] + qr[i+1] - 1] % mod; ans %= mod;
            ans += a[i-1] * qr[i+1] % mod * Exp[ql[i-1] + qr[i+1] - 1] % mod; ans %= mod;
            ans += ql[i-1] * qr[i+1] % mod * Exp[ql[i-1] + qr[i+1] - 2] % mod; ans %= mod;
        }
    }
    
    print(ans);
}


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

#define dump(a) (cerr << #a << " = " << (a) << endl)


const double EPS = 1e-9;

struct point {
	double x, y;
	point(double x = 0.0, double y = 0.0):x(x), y(y) {}
	point(const point& p):x(p.x), y(p.y) {}

	point operator+ (const point& p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point& p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (const double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point& p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (const double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point& p) const {
		return x + EPS < p.x || (abs(x - p.x) < EPS && y + EPS < p.y);
	}

	bool operator== (const point& p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

inline point rotate(const point& p, const double theta) {
	const double s = sin(theta); const double c = cos(theta);
	return point(c * p.x - s * p.y, s * p.x + c * p.y);
}

inline double norm(const point& p) {
	return p.x * p.x + p.y * p.y;
}

inline double dot(const point& l, const point& r) {
	return l.x * r.x + l.y * r.y;
}

inline double cross(const point& l, const point& r) {
	return l.x * r.y - l.y * r.x;
}

inline int ccw(const point& a, point b, point c) {
	b = b - a;
	c = c - a;
	const double tmp = cross(b, c);
	if(tmp > EPS) return 1; // ccw
	if(tmp < -EPS) return -1; // cw
	if(dot(b, c) < 0) return 2; // c, a, b 順に一直線上
	if(norm(b) < norm(c)) return -2; // a, b, c 順に一直線上
	return 0; //a, c, b 順で一直線上
}

inline double areaTriangle(point a, point b, const point& c) {
	a = a - c;
	b = b - c;
	return abs(cross(a, b)) / 2.0;
}

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

	const point O(0, 0);
	point center(x, y);

	vector<int> p(n);
	for(int i = 0; i < n; ++i) {
		cin >> p[i];
	}

	const double S = r * r * M_PI;

	vector<double> s_prev(n);
	for(int i = 0; i < n; ++i) {
		s_prev[i] = S * p[i] / 100.0;
	}

	vector<double> s_s(s_prev);
	point prev(0, r);

	for(int i = 0; i < n; ++i) {
		const double a = M_PI * p[i] / 50.0;
		point current = rotate(prev, -a);
		const double s_O = areaTriangle(prev, current, O);
		const double s_center = areaTriangle(prev, current, center);

		if(p[i] > 50) {
			s_s[i] += s_O;
			if(ccw(prev, current, O) * ccw(prev, current, center) == -1) s_s[i] += s_center;
			else s_s[i] -= s_center;
		}
		else if(p[i] == 50) {
			if(ccw(prev, current, center) == 1) s_s[i] -= s_center;
			else s_s[i] += s_center;
		}
		else {
			s_s[i] -= s_O;
			if(ccw(prev, current, O) * ccw(prev, current, center) == -1) s_s[i] -= s_center;
			else s_s[i] += s_center;
		}

		prev = current;
	}

	for(int i = 0; i < n; ++i) {
		cout << static_cast<int>(s_s[i] / s_prev[i] * 100.0) << (i + 1 == n ? "\n" : " ");
	}

	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int p[N];
  int x[N];
  int a[N];
  a[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
    x[p[i]] = i;
  }
  for (int i = 1; i < N; i++) {
    if (x[i-1] < x[i]) {
      a[i] = a[i-1] + 1;
    } else {
      a[i] = 1;
    }
  }
  int st = 0;
  for (int i = 0; i < N; i++) {
    st = max(st,a[i]);
  }
  int ans = N-st;
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 3224
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n = II()
a = LI()
d = [0]*n
d[1] = abs(a[1]-a[0])
for i in range(2,n):
	d[i] = min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]))
print(d[-1])

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

int main() {
 int R;
 int G;
  //Rは現在のレート,Gは取るべき点数
  //R,Gで入力を受け取る
  cin>> R;
  cin>> G;
    cout << (G*2)-R << endl;
    
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)
typedef pair<ll, int> PLI;

int main(void){
	int c[3][3],a[3],b[3],i,j;
	bool flag = true;
	for(i=0; i<3; i++){
		for(j=0; j<3; j++){
			cin >> c[i][j];
		}
	}
	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];
	for(i=0; i<3; i++){
		for(j=0; j<3; j++){
			if(c[i][j] != a[i] + b[j]){
				flag = false;
				break;
			}
		}
		if(!flag){
			break;
		}
	}
	cout << ((flag)?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int a,b,c,d;
}A[51];
int now[51],ans=-1;
int main(){
    int n,m,q,s=0;
    cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
		cin>>A[i].a>>A[i].b>>A[i].c>>A[i].d;
	for(int i=1;i<n;i++)
	    now[i]=1;
	while(now[0]==0){
		int sum=0;
		for(int i=1;i<=q;i++)
			if(now[A[i].b]-now[A[i].a]==A[i].c)
			    sum+=A[i].d;
		ans=max(ans,sum);
		for(int i=n;i>=0;i--){
			if(now[i]<m){
				now[i]++;
				for(int j=i+1;j<=n;j++)
				    now[j]=now[j-1];
				break;
			}
		}
	}
	cout<<ans;
    return 0;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  vii d(n, 0);
  rep(i, 0, n) cin >> d[i];
  sort(ALL(d));
  cout << d[n/2] - d[(n-1)/2] << endl;
  return 0;
}




Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	 
	public static void main(String[] args) throws IOException {
		Main main = new Main();
		main.run();
	}
 
	private void run() throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		if(s.substring(2,3).equals(s.substring(3,4)) && s.substring(4,5).equals(s.substring(5,6))) {
			out.println("Yes");
		}else {
			out.println("No");
		}
		out.flush();
		br.close();
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int a[N],s[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int gcd(int x,int y) {
    return y?gcd(y,x%y):x;
}
int main() {
    int n,k;
    cin>>n>>k;
    if(n==1) return puts(gi()==k?"POSSIBLE":"IMPOSSIBLE"),0;
    for(int i=1;i<=n;i++) a[i]=gi(),s[i]=gcd(s[i-1],a[i]);
    for(int i=n,g=0;i;i--) {
	int c=gcd(s[i-1],g);
	if(a[i]>=k&&a[i]%c==k%c) return puts("POSSIBLE"),0;
	g=gcd(a[i],g);
    }
    puts("IMPOSSIBLE");
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str ;
		String str2 = br.readLine();
		int a;
		int b;
		int num = Integer.parseInt(br.readLine());
		StringBuffer sb1 = new StringBuffer(str2);

		for (int i = 0; i < num; i++) {
			String[] str3 = br.readLine().split(" ");
			a = Integer.parseInt(str3[1]);
			b = Integer.parseInt(str3[2]);

			if (str3[0].equals("print")) {
				System.out.println(str2.substring(a, b + 1));
			}else if (str3[0].equals("reverse")) {
				StringBuffer sb2 = new StringBuffer(str2.substring(a, b + 1));
				str = sb2.reverse().toString();
				str2 = sb1.replace(a, b + 1, str).toString();
			}else if (str3[0].equals("replace")) {
				str2 = sb1.replace(a, b + 1, str3[3]).toString();
			}
		}
	}
}




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

int alp[30];

int main() {
    string s;
    cin >> s;
    string t = "";

    rep(i, s.size()) {
        if (s[i] != 'x') t += s[i];
        else {
            alp[s[i]-'a']++;
        }
    }

    if (t.size() == 0) {
        string tt = s;
        reverse(tt.begin(), tt.end());
        if (s != tt) {
            cout << -1 << endl;
            return 0;
        }
        else {
            cout << 0 << endl;
            return 0;
        }
    }

    string tt = t;
    reverse(tt.begin(), tt.end());
    if (t != tt) {
        cout << -1 << endl;
        return 0;
    }

    //cout << t << " " << tt << endl;

    int l = 0, r = s.size()-1;
    ll ans = 0;
    while (r-l > 0) {
        if (s[l] == s[r]) {
            l++;
            r--;
        }
        else if (s[l] == 'x' and s[r] != 'x') {
            ans++;
            l++;
        }
        else {
            ans++;
            r--;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n,k;
  cin >> n >> k;
  vll p(n);
  rep(i,0,n) {
    cin >> p[i];
    p[i]++;
  }
 ll res=0; 
  rep(i,0,k) res+=p[i];
  
  ll x=res;
  rep(i,k,n) {
    x-=p[i-k];
    x+=p[i];
    res=max(res,x);
  }
  
  cout << setprecision(12) << double(res)/2.0 << endl;
  
}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll n,c=0;
  cin>>n;
  ll a[n],b[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  for(int i=0;i<n;i++)
  cin>>b[i];
  for(int i=0;i<n;i++)
  {
      ll x=a[i]-b[i];
      if(x>0)
      c=c+x;
  }
  cout<<c;}

Measured memory_bytes: 3628