akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
  int n,wl,i,j,w,v,wb;
  vector<int> vw[5];
  cin >> n >> wl;
  for (i=0;i<n;i++){
    cin >> w >> v;
    if (i==0) wb=w;
    vw[w-wb].push_back(v);
  }
  for (i=0;i<4;i++) sort(vw[i].begin(),vw[i].end(),greater<int>());
  
  int i1,i2,i3,i4,vs1=0,vs2,vs3,vs4,wl1,wl2,wl3,ans=0;
  for (i1=0;i1<=vw[3].size() && i1*(wb+3)<=wl;i1++){
    wl1=wl-i1*(wb+3);
    vs2=0;
    for (i2=0;i2<=vw[2].size() && i2*(wb+2)<=wl1;i2++){
      wl2=wl1-i2*(wb+2);
      vs3=0;
      for (i3=0;i3<=vw[1].size() && i3*(wb+1)<=wl2;i3++){
        wl3=wl2-i3*(wb+1);
        vs4=0;
        i4=0;
        while (i4<=vw[0].size() && (i4+1)*wb<=wl3){
          vs4+=vw[0][i4];
          i4++;
        }
        if (ans<vs1+vs2+vs3+vs4) ans=vs1+vs2+vs3+vs4;
        if (i3==vw[1].size()) break;
        vs3+=vw[1][i3];
      }
      if (i2==vw[2].size()) break;
      vs2+=vw[2][i2];
    }
    if (i1==vw[3].size()) break;
    vs1+=vw[3][i1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
int32_t main()
{
    IOS;
    double r; cin>>r;
    //std::setprecision(6);
    double ans=2*3.141592653589793238462643383279502884*r;
    //cout<<M_PI;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3800
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);

   int A = sc.nextInt();
   int B = sc.nextInt();
   int C = sc.nextInt();
   int X = sc.nextInt();
   int Y = sc.nextInt();
   
   int a =0;
   if(X>Y)
   {
     int[] ans ={2*C*X,2*C*Y+A*(X-Y),A*X+B*Y};
     Arrays.sort(ans);
     a=ans[0];
   }
   else
   {
     int[] ans2 ={2*C*Y,2*C*X+B*(Y-X),A*X+B*Y};
     Arrays.sort(ans2);
     a=ans2[0];
   }
   System.out.println(a);
 }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N;
    scanf("%lld", &N);

    ll ac = 0, wa = 0, tle = 0, re = 0;
    for (ll i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        if (s == "AC")
            ac++;
        else if (s == "WA")
        {
            wa++;
        }
        else if (s == "TLE")
        {
            tle++;
        }
        else if (s == "RE")
        {
            re++;
        }
    }

    printf("AC x %lld\n", ac);
    printf("WA x %lld\n", wa);
    printf("TLE x %lld\n", tle);
    printf("RE x %lld\n", re);
}


Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
using namespace std;
 
int main (void) {
  int a[3]={0}, b[3]={0};
  int c[3][3]={0};
  a[0]=0;
  for (int i=0; i<=2; i++) {
    for (int j=0; j<=2; j++) {
      cin >> c[i][j];
    }
    b[i]=c[0][i];
    if (i>=1){
      a[i]=c[i][0]-b[0];
    }
  }
  for (int i=0; i<=2; i++) {
   for (int j=0; j<=2; j++) {    
    if (a[i]+b[j] != c[i][j]) {
      cout  << "No";
      return 0;
    }
   }
  }
  cout << "Yes";
}

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

void yes(void) {
	puts("Yes");
	exit(0);
}

int main(void) {
	int A, B, C;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	if (A == B && A != C) yes();
	if (A == C && A != B) yes();
	if (B == C && A != B) yes();
	puts("No");
	return 0;
}


Measured memory_bytes: 128
n = int(input())
cc = [int(input()) for i in range(n)]
c = [cc[0]]
for i in range(1,n):
  if cc[i] != cc[i-1]:
    c.append(cc[i])

n = len(c)
dp = [0 for i in range(n)]
pos_dp = [-1 for i in range(2*10**5+1)]

dp[0] = 1
pos_dp[c[0]] = 0
     
for i in range(1,n):
  if pos_dp[c[i]]!=-1:
    dp[i] = (dp[i-1] + dp[pos_dp[c[i]]])%1000000007
  else:
    dp[i] = dp[i-1] 
  pos_dp[c[i]] = i

print(dp[n-1])

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

int main(){
    int64_t N,M;
    cin >> N >> M;
    if ((N==1)&&(M==1)){
        cout << 1 << endl;
    }
    else if((N==1)||(M==1)){
        cout << N*M-2 << endl; 
    }
    else{
        cout << (N-2)*(M-2) << endl;
    }
}

Measured memory_bytes: 3540
// Painting

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

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

    int total = 0;
    int count = 0;
    while (total < N) {
        if (H > W) {
            total += H;
            W--;
        }
        else {
            total += W;
            H--;
        }
        count++;
    }
    cout << count << endl;

    return 0;
}

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

int main()
{
	long double a, b, c;
	long double x, tg;
	scanf("%Lf %Lf %Lf", &a, &b, &c);
	if (a*a*b/2 >= c)
	{	
		x = 2*c/(a*b);
		tg = atan(b/x);
	}
	else
	{
		x = (2*c - a*a*b)/(a*a);
		tg = atan((b-x)/a);
	}
	tg = tg * 180 / acos(-1);
	
	printf("%.10Lf", tg);
	return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MaxN = 1e5 + 15;

int n, mod;

vector <int> v[MaxN];
int dp[MaxN];
vector <int> pref[MaxN], suf[MaxN];
int ans[MaxN];

int pDP[MaxN];

void add(int & x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}

void prod(int & x, int y)
{
    x = (long long) x * y % mod;
}

void dfs(int x, int p = 0)
{
    if(p)
        for(int i = 0; i < v[x].size(); ++i)
            if(v[x][i] == p)
            {
                v[x].erase(v[x].begin() + i);
                break;
            }

    int n = v[x].size();

    pref[x].resize(n);
    suf[x].resize(n);

    for(int i = 0; i < n; ++i)
    {
        dfs(v[x][i], x);

        pref[x][i] = (1 + dp[v[x][i]]) % mod;

        if(i)
        {
            prod(pref[x][i], pref[x][i - 1]);
        }
    }
    for(int i = n - 1; i >= 0; --i)
    {
        suf[x][i] = (1 + dp[v[x][i]]) % mod;

        if(i + 1 < n)
        {
            prod(suf[x][i], suf[x][i + 1]);
        }
    }

    dp[x] = (suf[x].empty() ? 1 : suf[x][0]);
}

void dfs2(int x, int p = 0, int pos = -1)
{
    if(p)
    {
        pDP[x] = (pDP[p] + 1) % mod;
        if(pos > 0)
            prod(pDP[x], pref[p][pos - 1]);
        if(pos + 1 < v[p].size())
            prod(pDP[x], suf[p][pos + 1]);
    }

    int i = 0;
    for(int to : v[x])
        dfs2(to, x, i++);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
    cin >> n >> mod;

    for(int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1);
    dfs2(1);

    for(int i = 1; i <= n; ++i)
    {
        int ans = (long long) dp[i] * (1 + pDP[i]) % mod;
        cout << ans << '\n';
    }

    return 0;
}



Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;

int main()
{
    ll a,b,q;
    cin >> a >> b >> q;
    vector<ll> s, t;

    s.push_back(-10e17);
    t.push_back(-10e17);
    for (ll i = 0; i < a; i++)
    {
        ll temp;
        cin >> temp;
        s.push_back(temp);
    }
    for (ll i = 0; i < b; i++)
    {
        ll temp;
        cin >> temp;
        t.push_back(temp);
    }
    s.push_back(10e17);
    t.push_back(10e17);

    for(ll i = 0; i < q; i++)
    {
        ll temp;
        cin >> temp;

        // abs(min( - temp,  - temp)) + abs(t[i] - s[i])
        vector<ll> vx, vy;
        vx.push_back(*upper_bound(s.begin(), s.end(), temp)-temp);
        vx.push_back(*(upper_bound(s.begin(), s.end(), temp) - 1)-temp);
        vy.push_back(*(upper_bound(t.begin(), t.end(), temp) - 1)-temp);
        vy.push_back(*upper_bound(t.begin(), t.end(), temp)-temp);

        ll ans = __LONG_LONG_MAX__;
        for(ll i = 0; i < vx.size(); i++)
        {
            for(ll k = 0; k < vy.size(); k++)
            {
                ll _temp = abs(vx[i] - vy[k]) + min(abs(vx[i]), abs(vy[k]));
                if(ans > _temp)
                    ans = _temp;
            }            
        }
        
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 3060
N, M = map(int, input().split())
l = [0] * (M + 1)
for _ in range(N):
  a = list(map(int, input().split()))
  for i in range(1, a[0] + 1):
    l[a[i]] += 1

ans = 0
for i in range(1, M + 1):
  if l[i] == N:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
//#include <cassert>
//#include <stack>
//#include <queue>
//#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;


void solve() {
	string s;
	cin >> s;
	string t = s;
	reverse(all(t));
	if (s != t) {
		cout << "No\n";
		return;
	}
	
	int n = sz(s);
	s = '#' + s;
	string s1 = "", s2 = "";
	for (int i = 1; i <= (n - 1) / 2; ++i) {
		s1.pb(s[i]);
	}
	for (int i = (n + 3) / 2; i <= n; ++i) {
		s2.pb(s[i]);
	}
	string t1 = s1, t2 = s2;
	reverse(all(t1));
	reverse(all(t2));
	if (s1 == t1 && s2 == t2) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
ц*/

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, m;
int a[100100], b[100100];
vector<int> G[100100];

int label[100100];

bool dfs(int v, int b) {
    label[v] = b;
    for (int u : G[v]) {
        bool res = true;
        if (label[u] < 0) {
            res = dfs(u, 1-b);
        } else if (label[u] == b) {
            res = false;
        }
        if (!res)
            return false;
    }
    return true;
}

bool is_bipartite() {
    memset(label, -1, sizeof(label));
    return dfs(0, 0);
}

ll solve() {
    for (int i = 0; i < m; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    if (is_bipartite()) {
        ll n0 = 0, n1 = 0;
        for (int i = 0; i < n; i++) {
            if (label[i] == 0) n0++;
            else n1++;
        }
        return n0 * n1 - m;
    } else {
        return n * (n-1) / 2 - m;
    }
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 7296
#Remainder Minimization 2019
L,R=map(int,input().split())
l=L%2019
r=R%2019
if R-L>=2018:
    print(0)
elif r<l:
    print(0)
else:
    a=float("inf")
    for i in range(l,r):
        for j in range(i+1,r+1):
            a=min(a,(i*j)%2019)
    print(a)

Measured memory_bytes: 40812
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(u == s) a--;
	else b--;
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    p = list(map(int, input().split()))
    min = p[0]
    cnt = 0
    for i in p:
        if i <= min:
            cnt += 1
            min = i
        else:
            pass
    print(cnt)


if __name__=="__main__":
    main()


Measured memory_bytes: 103580
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

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

const int Maxn = 100010;
const ll INF = (ll) 1e16;

ll s[Maxn], t[Maxn];
int n, m, q;

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

    cin >> n >> m >> q;
    s[0] = t[0] = -INF;
    s[n + 1] = t[m + 1] = INF;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> t[i];
    }
    while (q--) {
        ll x;
        cin >> x;
        ll ys[2], yt[2];
        auto itr = lower_bound(s, s + n + 2, x);
        ys[1] = *itr;
        --itr;
        ys[0] = *itr;
        itr = lower_bound(t, t + m + 2, x);
        yt[1] = *itr;
        --itr;
        yt[0] = *itr;
        ll ans = 2 * INF;
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                ll d1 = abs(x - ys[i]) + abs(ys[i] - yt[j]);
                ll d2 = abs(x - yt[j]) + abs(yt[j] - ys[i]);
                ans = min(ans, min(d1, d2));
            }
        }

        cout << ans << endl;
    }

}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
int main()
{
    int x, y; cin >> x >> y;
    x--, y--;
    int group[12] = {1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
    cout << (group[x] == group[y] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
typedef long long ll;
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    int sum=0;
    
    cin >> N;

    int W[N];
    for( int ni = 0 ; ni < N ; ni++ ){
        cin >> W[ni];
        sum+=W[ni];
    }

    int ans=sum;
    int sum1=0;
    rep(ni,N){
        sum1+=W[ni];
        if(ni+1<N){
            if(sum1 + W[ni+1] > sum/2) ans = min(ans,abs(sum1 - (sum - sum1)));
        }

    }

    cout << ans  << endl;

}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int p[200005];
void solve() {
    cin >> n;
    rep(i, n) cin >> p[i];

    int mi = p[0];
    int ans = 0;
    rep(i, n) {
        if (mi >= p[i]) ++ans;
        mins(mi, p[i]);
    }

    cout << ans << endn;

}

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


Measured memory_bytes: 1024
#include<stdio.h>
#define N 44
typedef struct Fibonacci{
  int value;
  int flag;
} fib;
int calFib(int);
fib f[N];
int main() {
  int n;
  
  f[0].value = 1; f[0].flag = 1;
  f[1].value = 1; f[1].flag = 1;

  scanf("%d", &n);
  printf("%d\n", calFib(n));

  return 0;
}
int calFib(int u) {
  if (u < 2) return f[0].value;
  if (f[u].flag == 1) {
    f[u].flag = 1;
    return f[u].value;
  }

  f[u].value = calFib(u-2) + calFib(u-1);
  f[u].flag = 1;
  return f[u].value;
}

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

using namespace std;

long maxSubArray(long arr[], int n)
{
	long maximum = arr[0];
	long currentMaximum = arr[0];
	long sum;
	for(int i = 1; i < n; i++) {
		sum = currentMaximum + arr[i];
		currentMaximum = max(arr[i], sum);
		maximum = max(maximum, currentMaximum);
	}
	return maximum;
}




int main()
{
	//freopen("input.txt", "r", stdin);
	long n;
	while(scanf("%ld", &n) == 1 && n != 0) {
		long arr[200001];
		for(int i = 0; i < n; i++) {
			cin >> arr[i];
		}

		cout << maxSubArray(arr, n) << endl;
	}

	return 0;
}

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

//https://atcoder.jp/contests/abc074/tasks/arc083_b

int n, a[300][300];
ll ans = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];

	for (int i = 0; i < n - 1; ++i)
		for (int j = i + 1; j < n; ++j) {
			bool flag = 1;
			for (int k = 0; k < n; ++k) {
				if (k == i || k == j)
					continue;
				if (a[i][j] > a[i][k] + a[k][j]) {
					cout << -1 << endl;
					return 0;
				} else if (a[i][j] == a[i][k] + a[k][j])
					flag = 0;
			}
			if (flag)
				ans += a[i][j];
		}
	cout << ans << endl;
}


Measured memory_bytes: 3980
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			int[][] a = new int[h][w];
			IntStream.range(0, h).forEach(i -> IntStream.range(0, w).forEach(j -> a[i][j] = scanner.nextInt()));
			List<Move> moves = new ArrayList<>(), currentMoves = new ArrayList<>();
			int prevX = -1, prevY = -1;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					int x = i, y = (0 == (x & 1)) ? j : w - 1 - j;
					if ((prevX >= 0) && (prevY >= 0)) {
						currentMoves.add(new Move(prevX, prevY, x, y));
						if (0 != (a[x][y] & 1)) {
							prevX = -1;
							prevY = -1;
							moves.addAll(currentMoves);
							currentMoves.clear();
						} else {
							prevX = x;
							prevY = y;
						}
					} else if (0 != (a[x][y] & 1)) {
						prevX = x;
						prevY = y;
					}
				}
			}
			System.out.println(moves.size());
			moves.stream().forEach(System.out::println);
		}
	}

	/**
	 * 移動方法を表すクラス
	 */
	private static class Move {
		int x1, y1, x2, y2;

		Move(int x1, int y1, int x2, int y2) {
			super();
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
		}

		@Override
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append(x1 + 1).append(" ");
			sb.append(y1 + 1).append(" ");
			sb.append(x2 + 1).append(" ");
			sb.append(y2 + 1);
			return sb.toString();
		}
	}
}


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

typedef long long ll;

map<ll, int> book;
ll ans, t, psum;
int n;

int main() {
	scanf("%d", &n);
	while (n--) {
		scanf("%lld", &t);
		psum += t;
		ans += book[psum] + !psum;
		book[psum]++;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a + b >= k)
        cout << min(a, k) << endl;
    else
        cout << a + (k - a - b) * -1 << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int inf = 1 << 29;

    vector<vector<int>> dp(h, vector<int>(w, inf));
    dp[ch][cw] = 0;

    priority_queue<tuple<int, int, int>,
            vector<tuple<int, int, int>>,
            greater<tuple<int, int, int>>> que;
    que.push(make_tuple(0, ch, cw));
    while (!que.empty()) {
        tuple<int, int, int> q = que.top();
        que.pop();

        int y = get<1>(q);
        int x = get<2>(q);

        int dy[] = { -1, 0, 0, 1 };
        int dx[] = { 0, -1, 1, 0 };
        for (int i = 0; i < 4; i++) {
            if (0 <= y + dy[i] && y + dy[i] < h
                    && 0 <= x + dx[i] && x + dx[i] < w
                    && s[y + dy[i]][x + dx[i]] == '.'
                    && dp[y + dy[i]][x + dx[i]] > dp[y][x]) {
                dp[y + dy[i]][x + dx[i]] = dp[y][x];
                que.push(make_tuple(dp[y + dy[i]][x + dx[i]], y + dy[i], x + dx[i]));
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (0 <= y + i && y + i < h
                        && 0 <= x + j && x + j < w
                        && s[y + i][x + j] == '.'
                        && dp[y + i][x + j] > dp[y][x] + 1) {
                    dp[y + i][x + j] = dp[y][x] + 1;
                    que.push(make_tuple(dp[y + i][x + j], y + i, x + j));
                }
            }
        }
    }

    cout << (dp[dh][dw] < inf ? dp[dh][dw] : -1) << endl;
}


Measured memory_bytes: 9596
n, m = map(int, input().split())
A = [[0 for col in range(m)] for row in range(n)]
b = [0 for element in range(m)]

# matrix
for row in range(n):
    temp = input().split()
    temp = [int(a) for a in temp]
    for col in range(m):
        A[row][col] = temp[col]
# vector
for row in range(m):
    temp = int(input())
    b[row] = temp
# calc.
for row in range(n):
    sum = 0
    for col in range(m):
        sum += A[row][col] * b[col]
    print(sum)


Measured memory_bytes: 5788
k,s = input().strip().split(' ')
k,s = [int(k),int(s)]
cnt = 0
for i in range(k+1):
	if i>s:	
		break;
	for j in range(k+1):
		if i+j>s:
			break;
		elif s-i-j<=k:
			cnt+=1
print (cnt)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int h,w,i,j;
    for(;;){
    cin>>h>>w;
    if(h==0)exit(0);
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i==0||i==h-1){cout<<"#";}
            else if(j==0||j==w-1){cout<<"#";}
            else{cout<<".";}
        }
        cout<<endl;
    }
    cout<<endl;
}
return 0;
}

Measured memory_bytes: 3016
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */
 
#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;
 
template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}
 
template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}
 
template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }
 
template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }
 
#define Pa pair<int, int> 
const int P = 1e9 + 7;
const int N = 305;
int f[N][N][N], m, n;
vector<Pa> v[N];
 
inline void add(int &x, int y) {
	x += y, (x >= P) && (x -= P);
}
 
int main() {
	read(n), read(m);
	for (int i = 1, l, r, x;i <= m; i++)
		read(l), read(r), read(x), v[r].push_back(MP(l, x));
	f[0][0][0] = 1;
	for (int i = 1;i <= n; i++) {
		for (int j = 0;j < i; j++) {
			for (int k = 0;k <= j; k++) {
				add(f[i][j][k], f[i-1][j][k]);
				add(f[i][i-1][k], f[i-1][j][k]);
				add(f[i][i-1][j], f[i-1][j][k]);
			}
		}
		for (auto t: v[i]) {
			int l = t.fi;
			for (int j = 0;j < i; j++) 
				for (int k = 0;k <= j; k++) {
					int ct = (j >= l) + (k >= l) + 1;
					if (ct != t.se) f[i][j][k] = 0;
				}
		}
	}
	int ans = 0;
	for (int i = 0;i < n; i++)
		for (int j = 0;j <= i; j++)
			add(ans, f[n][i][j]);
	write(ans);
	return 0;
}

Measured memory_bytes: 57868
// ref. https://atcoder.jp/contests/keyence2020/submissions/9549557

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

using namespace std;

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

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

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

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

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }

  // dp[mask][k] .. minimum count when mask is selected and k is last.
  vector<vector<ll>> dp(1ll<<n, vector<ll>(n, INF));
  ll m = 1ll << n;
  rep(i, n) {
    dp[1ll<<i][i] = 0;
  }
  rep(i, m) { // i is current state
    ll c = __builtin_popcount(i);
    ll cnt = c; // inversion number
    rep(j, n) { // j is last element
      if ((1ll<<j) & i) {
        --cnt; // e.g. when first element is located at k, then inversion number is k-1 (1-indexed)
        ll pre = i^(1ll<<j); // pre is prev state
        rep(k, n) {
          if ((1ll<<k) & pre) { // k is prev element
            ll prv = (c^k)%2 ? b[k] : a[k]; // c is 1-indexed, k is 0-indexed.
            ll cur = (c^j)%2 ? a[j] : b[j];
            if (prv <= cur) { // valid
              chmin(dp[i][j], dp[pre][k] + cnt);
            }
          }
        }
      }
    }
  }

  ll ans = INF;
  rep(i, n) {
    chmin(ans, dp[m-1][i]);
  }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int gcd(int a, int b) {
	if(b) return gcd(b, a % b);
	return a;
}

int main(){
	int n, x; cin >> n >> x; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int g = std::abs(a[0] - x);
	for(int i = 0; i < n; i++) g = gcd(g, std::abs(a[i] - x));
	cout << g << endl;
	return 0;
}


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

int main(int argc, char const *argv[])
{
    int ans = 0, n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if((to_string(i).length()) % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A,B,K;
    int i,j;

    scanf("%d %d %d",&A,&B,&K);

    for(i=0;i<K && A+i-1<B;i++){
        printf("%d \n",A+i);
    }

    for(j=0;j<K;j++){
        if(B-K+j+1>A+K-1 && B+j-K+1>A-1){
        printf("%d \n",B-K+j+1);
        }  
    }
    return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/arc074/tasks/arc074_a

from math import floor


def solve(H, W):
    # hの全探索
    ans = 10 ** 10
    for h in range(1, H):
        SA = h * W

        # (1) A-B-C 均等割
        dh = floor((H - h) / 2)
        SB = dh * W
        SC = (H - h - dh) * W
        a1 = max(SA, SB, SC) - min(SA, SB, SC)
        ans = min(ans, a1)

        # (2) A-B|C
        w = floor(W / 2)
        SB = (H - h) * w
        SC = (H - h) * (W - w)
        a2 = max(SA, SB, SC) - min(SA, SB, SC)
        ans = min(ans, a2)
    return ans


if __name__ == '__main__':
    h, w = map(int, input().split())
    ans1 = solve(h, w)
    ans2 = solve(w, h)
    print(min(ans1, ans2))

Measured memory_bytes: 42732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

string s[311];
bool a[311][311][311];

int main()
{
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL);
	//freopen("stress.txt","r",stdin);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			bool same = 1;
			for(int k = 0; k < n; k++){
				if((s[(i+k)%n][j]!=s[i][(j+k)%n])){
					same=0;
				}
				a[i][j][k]=same;
			}
		}
	}
	int ans=0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			bool pos = 1;
			for(int k = 0; k < n; k++){
				if(a[(i+k)%n][(j+k)%n][n-1-k]==0){
					pos=0;
				}
			}
			ans+=pos;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 29056
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int start=0,end=n-1,count=0;
    while (1) {
        if (s[end]=='R') {
            while (1) {
                if (s[start]=='W') {
                    swap(s[start],s[end]);
                    count++;
                    start++;
                    break;
                } else {
                    start++;
                }
                if (start==n+1||start>=end) {
                    break;
                }
            }
            end--;
        } else {
            end--;
        }
        if (start>=end) {
            break;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3740
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			String[] ss = sc.nextLine().split(" ");
			if (ss.length == 1 && ss[0].equals("0")) break;
			int[] as = new int[ss.length];
			for (int i = 0; i < ss.length; i++) {
				as[i] = Integer.parseInt(ss[i]);
			}
			Arrays.sort(as);
			
			int ans = 0;
			int one = 0;
			for (int x : as) {
				if (x == 1) {
					ans += 1;
					one++;
				}
				else if (x >= 10) {
					ans += 10;
				}
				else {
					ans += x;
				}
			}
			for (int i = 0; i < one; i++) {
				if (ans + 10 <= 21) ans += 10;
			}
			if (ans > 21) ans = 0;
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 19168
class a(object):
    def __init__(self, buf_size=10000000):
        self.m = [None for _ in range(buf_size)]
        self.ind = 0
        self.cur = 0

    def enqueue(self, elem):
        self.m[self.ind] = elem
        self.ind += 1

    def dequeue(self):
        if self.is_empty(): raise EOFError('this queue is empty')
        result = self.m[self.cur]
        self.cur += 1
        return result

    def is_empty(self):
        return self.ind <= self.cur

n, q = input().split()
qe = a()
cur_time = 0

for _ in range(int(n)):
    name, time = input().split()
    qe.enqueue((name, int(time)))

while not qe.is_empty():
    name, time = qe.dequeue()
    if time > int(q):
        cur_time += int(q)
        time -= int(q)
        qe.enqueue((name, time))
    else:
        cur_time += int(time)
        print('{} {}'.format(name, cur_time))


Measured memory_bytes: 102140
m,d = gets.chomp.split.map(&:to_i)
cnt = 0
(1..m).each do|k|
  (0..d).each do|i|
    if (i/10)*(i%10) == k && i/10 >= 2 && i%10>=2
      cnt += 1
    end
  end
end
puts cnt

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

int main() {
	int N, K, S;
	cin >> N >> K >> S;
	for (int i = 0; i < K; i++) {
		cout << S << " ";
	}

	for (int i = 0; i < N - K; i++) {
		cout << (S == 1000000000 ? S - 1 : S + 1) << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int m,n,i,j;
  int a[100][100];
  int b[100];
  int c[100] = {0};
  
  scanf("%d%d",&n,&m);
  
  for(i = 0;i < n;i++){
    for(j = 0;j < m;j++){
      scanf("%d",&a[i][j]);
      }
  }
  
  for(i = 0;i < m;i++){
    scanf("%d",&b[i]);
  }
  
  for(i = 0;i < n;i++){
    for(j = 0;j < m;j++){
      c[i] += a[i][j]*b[j];
  }
    printf("%d\n",c[i]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

priority_queue <long long> first_half;
priority_queue < long long, vector <long long>, greater <long long> > last_half;
long long b_sum;
long long min_value;
void update(long long a){
    long long first_top;
    long long last_top;
    if(!first_half.empty() && !last_half.empty()){
        first_top = first_half.top();
        last_top = last_half.top();

        if(a <= first_top){
            min_value += first_top - a;
        }    
        if(a >= last_top){
            min_value += a - last_top;
        }
    }
    first_half.push(a);
    last_half.push(a);
    if(first_half.top() > last_half.top()){
        first_top = first_half.top();
        first_half.pop();
        last_top = last_half.top();
        last_half.pop();
        first_half.push(last_top);
        last_half.push(first_top);
    }
}

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

   for(int i = 0; i < Q; i++){
       int t;
       cin >> t;
       if(t == 1){
           long long a;
           long long b;
           cin >> a >> b;
           b_sum += b;
           update(a);
       } else {
           cout << first_half.top() << " " << min_value + b_sum << endl;
       }
   }

   return 0;
}


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


int main(){
    int n, k;
    string s;
    cin >>n>>k>>s;
    for(int i = 0; i < n; i++){
        if(i == k-1) cout << (char)tolower(s[i]);
        else cout << s[i];
    }
}


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

int N, X;

int main() {
  cin >> N >> X;
  int m[N];
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> m[i];
    sum += m[i];
  }

  X -= sum;
  int ans = N;
  sort(m, m + N);

  while (true) {
    if ((X -= m[0]) < 0) {
      break;
    } else {
      ++ans;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string S, T;
  int count=0, len;
  cin >> S >> T;
  
  len = S.length();
  
  for(int i=0; i<len; i++){
    //if(equal(S.begin()+i, S.begin()+i+1, T.begin()+i, T.end()+i+1)==0){
    //  count++;
    //}
    if(S[i]!=T[i]){
      count++;
    }
  }
  
  cout << count;
  
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;

	pii ans = {0, 0};
	while (n) {
		int x = n;
		int cnt = 0;
		while (x) {
			if (x % 2 == 0) {
				cnt++;
				x /= 2;
			} else {
				break;
			}
		}
		pii cur = {cnt, n};
		chmax(ans, cur);
		n--;
	}
	cout << ans.second << endl;
}


Measured memory_bytes: 256
// g++ MoveandWin.cpp -o MoveandWin
#include <iostream>
#include <cmath>
#define endl "\n"

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m,a,b;

	cin>>n;
		
	cin >> a >> b;
	m=abs(a-b);
	if(m&1)
		cout << "Borys"<< endl;
	else
		cout << "Alice"<< endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[]={1,3,5,7,8,10,12};
int b[]={4,6,9,11};
int main()
{
	int x,y,i;
	int f1=0,f2=0;
	scanf("%d %d",&x,&y);
	/*if(x==2||y==2)
	{
		printf("No\n");
	}*/
	for(i=0;i<7;i++)
	{
		if(a[i]==x)
		f1=1;
		if(a[i]==y)
		f2=1;
	}
	for(i=0;i<4;i++)
	{
		if(b[i]==x)
		f1=2;
		if(b[i]==y)
		f2=2;
	}
	if(f1==f2)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: String
    }
    println!("{}",
        match &s[..] {
            "Sunny" => "Cloudy",
            "Cloudy" => "Rainy",
            "Rainy" => "Sunny",
            _ => panic!()
        });
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

void solve()	{
	string s;
	cin >> s;
	int n = s.size();
	for(int i=n-2; i>=0; i--)	{
		if(i&1)	{
			//cout << s.substr(0,i/2+1) << " " << s.substr(i/2+1,i/2+1) << endl;
			if(s.substr(0,i/2+1) == s.substr(i/2+1,i/2+1))	{
				cout << i+1 << endl;
				return;
			}
		}
	}
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
N = int(input())
h_list = input().split()
h_list = [int(i) for i in h_list]
current_V = [0]
current_value = [0] * N
current_value[1]=abs(h_list[0]-h_list[1])
for i in range(2,N) :
    current_value[i]=min(current_value[i-1]+abs(h_list[i-1]-h_list[i]),current_value[i-2]+abs(h_list[i-2]-h_list[i]))

print(current_value[-1])

Measured memory_bytes: 52208
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int p[200000];
    int sum=0;
    int low=200000000;
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(low>p[i]){
            sum++;
            low=p[i];
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int result = 0;
        int[] subResults = new int[n];
        for (int i = 0; i < n; i++) {
            subResults[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            subResults[i] -= scanner.nextInt();
            if (subResults[i] > 0) {
                result += subResults[i];
            }
        }
        System.out.println(result);
    }
}


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

int main() {
 int N,Y;
cin >> N >> Y;
bool a=true;
for(int i=0; i<=N; i++){
for(int j=0; j<=N; j++){
int k=N-i-j;
if(i*10000+5000*j+1000*k==Y && i+j+k==N &&k>=0){
cout << i << " "<< j <<" "<<  k << endl;
a=false;
break;
}
}
if(a==false){break;}
}
if(a){
cout << "-1" << " "<< "-1" << " "<< "-1" << endl;
}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCorder
{
    class Program
    {

        static void Main(string[] args)
        {
            int n, m;
            //List<City> cities = new List<City>();

            var ip1 = ReadLine().Split(' ');
            n = int.Parse(ip1[0]);
            m = int.Parse(ip1[1]);

            List<List<City>> sortedcs = new List<List<City>>();
            List<City> cities = new List<City>();
            for (int i = 0; i < n; i++)
            {
                sortedcs.Add(new List<City>());
                sortedcs[i] = new List<City>();
            }
            
            for (int i = 0;i < m;i++)
            {
                var ip = ReadLine().Split(' ');
                int p, y;
                p = int.Parse(ip[0]);
                y = int.Parse(ip[1]);
                sortedcs[p-1].Add(new City(p,y,i));
                cities.Add(new City(p,y,i));
            }

            for(int i = 0; i< n; i++)
            {
                sortedcs[i] = sortedcs[i].OrderBy(x=>x.y).ToList();
            }

            for(int i = 0;i < n; i++)
            {
                int rank = 1;
                foreach (var c in sortedcs[i])
                {
                    cities[c.citynum].id = string.Format("{0:000000}{1:000000}", c.p, rank);
                    rank++;
                }
            }

            for(int i = 0;i < cities.Count; i++)
            {
                WriteLine(cities[i].id);
            }

        }

        class City
        {
            public int y;
            public int p;
            public int citynum;
            public string id;
            public City(int p,int y,int cid)
            {
                this.y = y;
                this.p = p;
                citynum = cid;
            }
        }

        
    }
}


Measured memory_bytes: 51264
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll i, j, k;
  
  double x[3], y[3];
  for(i=0; i<3; i++) cin >> x[i] >> y[i];
  
  double d[3];
  for(i=0; i<3; i++) {
    double tx=abs(x[i]-x[(i+1)%3]);
    double ty=abs(y[i]-y[(i+1)%3]);
    d[i]=sqrt(tx*tx+ty*ty);
  }
  
  double a=max({d[0], d[1], d[2]});
  double x0=x[0]-x[2], y0=y[0]-y[2];
  double x1=x[1]-x[2], y1=y[1]-y[2];
  double S=abs(x0*y1-x1*y0)/2;
  double r=S*2/(d[0]+d[1]+d[2]);
  double ans=r*a/(r*2+a);
  
  printf("%.12f\n", ans);
    return 0;
}






Measured memory_bytes: 256