akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int a, b; cin >> a >> b;
    if((a+b) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (a+b)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  ll l,r;
  cin>>l>>r;
  ll k=((l+1)%2019*l%2019)%2019;
  bool ans=false;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<=r;j++){
      ll x=((i%2019)*(j%2019))%2019;
      if(x<k){k=x;}
      if(((i%2019)*(j%2019))%2019==0){k=0;ans=true;break;}}
  if(ans){break;}}
  cout<<k<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mx 100001
typedef long long L;
char str[mx+5];
void solve(){
	L l=strlen(str),c1=0,c2=0;
	for(L i=0;i<l;i++){
		if(i%2==0){
			if(str[i]=='0')c1++;
			else c2++;
		}
		else{
			if(str[i]=='1')c1++;
			else c2++;
		}
	}
	c1=min(c1,c2);
	printf("%lld\n",c1);
}

int main()
{
	scanf("%s",&str);
	solve();
	return 0;
}


Measured memory_bytes: 384
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <iostream>
#pragma GCC optimize(2)
using namespace std;
string s1[10005];
bool cmp(string a,string b){
	return a<b;
}
void print(){
	int n,l;
	cin>>n>>l;
	
	int i;
	for(i=0;i<n;i++)
		cin>>s1[i];
	sort(s1,s1+n,cmp);
	for(i=0;i<n;i++)
	    cout<<s1[i];
}
int main(void){
	ios::sync_with_stdio(false);
	print();
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] nums = new long[N+1];
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <=N ; j+=i) {
                nums[j]+=1;
            }
        }

        long ans= 0;
        for (int i = 1; i <= N; i++) {
            ans += nums[i]*i;
        }

        System.out.println(ans);
    }
}

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

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k){
    	cout<<s<<endl;
    	return 0;
	}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
int color[100 + 5];
int main(){
//	ios::sync_with_stdio(false);
//	ifstream cin("data.txt");
//	freopen("data.txt", "r", stdin);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> color[i];
	}
	int ans = 0;
	for(int i = 1; i < n; i++){
		if(color[i] == color[i - 1]){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  cout<<fixed<<setprecision(20);
  double x1,x2,y1,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))<<endl;
}



Measured memory_bytes: 3292
# ABC048C - Boxes and Candies
def main():
    n, x = list(map(int, input().rstrip().split()))
    A = list(map(int, input().rstrip().split()))
    ans = 0
    if A[0] > x:
        ans += A[0] - x
        A[0] = x
    for i in range(n - 1):
        dif = A[i] + A[i + 1] - x
        if dif > 0:
            A[i + 1] -= dif
            ans += dif
    print(ans)


if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	int x = 800 * N;
	int y = 200 * (N / 15);
	cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;


// Find Maximum Sub Square Matrix
int main() {
    int h, w;
    cin >> h >> w;

    int G[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int x;
            cin >> x;
            G[i][j] = x;
        }
    }

    int maxWidth = 0;
    int dp[h][w];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            // dp[i][j] = (G[i][j] + 1) % 2;
            dp[i][j] = G[i][j] == 0 ? 1 : 0;
            maxWidth |= dp[i][j];
        }
    }


    for (int i = 1; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if (G[i][j]) {
                dp[i][j] = 0;
            } else {
                // ?????????????????????????´??????????????°??????????1????????????????????????(i,j)???????????????????????£?????§???????????§?????£?????¢???????????????
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j], dp[i][j-1])) + 1;
                maxWidth = max(maxWidth, dp[i][j]);
            }
        }
    }
    cout << maxWidth * maxWidth << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vc(n);
    for (auto &a:vc) {
        cin >> a;
    }

    sort(vc.begin(), vc.end(), greater<>());

    int alice = 0, bob = 0;

    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0)alice += vc.at(i);
        else bob += vc.at(i);
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

const int maxn=2e5+7;
char a[maxn];
int in[maxn][2];
int vis[maxn];
queue<int> q;
int n,m;
vector<int>mp[maxn];

int main()
{
    n=read();m=read();
    scanf("%s",a+1);
    for(int i=1;i<=m;i++){
        int u=read(),v=read();
        mp[u].push_back(v);
        mp[v].push_back(u);
        in[u][a[v]-'A']++;
        in[v][a[u]-'A']++;
    }
    int res=0;
    for(int i=1;i<=n;i++){
        if(in[i][0]==0||in[i][1]==0)q.push(i),res++,vis[i]=1;
    }
//    for(int i=1;i<=n;i++){
//        if(vis[i])printf("%d ",i);
//    }
//    puts("");
//    printf("fuck %d %d %d\n",res,in[4][1],in[4][0]);
    while(q.size()){
        int x=q.front();q.pop();
        for(int i=0;i<mp[x].size();++i){
//            if(vis[i])continue;
            int now=mp[x][i];
//            printf("asd %d %d\n",x,now);
            in[now][a[x]-'A']--;
            if(in[now][a[x]-'A']==0&&vis[now]==0){
                q.push(now);
                vis[now]=1;
                res++;
            }
        }
    }
//    printf("test %d\n",res);
    if(res!=n)puts("Yes");
    else puts("No");
    return 0;
}


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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    vector<bool> f(n+1),s(n+1);
    for(int i=0; i<m; i++) {
        cin >> a[i] >> b[i];
        if(a[i] == 1) f[b[i]] = true;
        if(b[i] == n) s[a[i]] = true;
    }
    bool ok = false;
    for(int i=1; i<=n; i++) {
        if(f[i] && s[i]) ok = true;
    }
    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n,m;
    cin >> n >> m;
    int ans = 0;
    vi l(31,0);
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int x ;
            cin >> x;
            l[x]++;
        }
    }
    rep1(i,31){
        if(l[i]==n)ans++;
    }
    cout << ans <<endl;
    return 0;

}


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

using std::cout;
using std::endl;
using std::cin;
using std::string;
int main() {
	string W;
	string T;
	int sum = 0;
	cin >> W;
	// ??\????????§??????????????????
	for (size_t i = 0; i < W.size(); i++)
	{
		W[i] = toupper(W[i]);
	}
	
	while (1)
	{
		cin >> T;
		// ???????????¶
		if (T == "END_OF_TEXT")	break;
		// ??\????????§??????????????????
		for (size_t i = 0; i < T.size(); i++)
		{
			T[i] = toupper(T[i]);
		}

		// ????´¢
		if (W == T) sum++;
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=0; i<n; i++){
        ll x;
        cin >> x;
        ans += x-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
n_max = 0
place = 0
n_sum = sum(P[:K])
for i in range(N - K):
	n_sum = n_sum - P[i] + P[i+K]
	if n_max <= n_sum:
		n_max = n_sum
		place = i + 1
for i in range(place,place + K):
	ans += (1 + P[i]) /2 
print(ans)

Measured memory_bytes: 25604
import math
A, B, H, M = map(int, input().split())
 
h = H*30 + M/2
m = 6*M
K = abs(h - m)
if K > 180:
  K = 360 - K
c = math.cos(math.radians(K))

aa = A**2 + B**2 -2*A*B*c

print(math.sqrt(aa))

Measured memory_bytes: 9508
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 102345;
int a[N], dp[N];

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1];
}

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;
int w,h;
char s[100][100];
int f[100][100];

// next step: left(0), right(1)
int dp[60][30][60][30][2];

struct State{
    int ly,lx,ry,rx,LR;
};

int main()
{
    while(scanf(" %d %d", &w, &h),w)
    {
        rep(i,h)rep(j,w)
        {
            scanf(" %c", &s[i][j]);
            if(s[i][j]=='X') f[i][j]=-1;
            else if(s[i][j]=='S' || s[i][j]=='T') f[i][j]=0;
            else f[i][j] = s[i][j]-'0';
        }

        // initialize
        rep(i,60)rep(j,30)rep(k,60)rep(l,30)rep(m,2) dp[i][j][k][l][m]=INF;

        queue<State> que;
        rep(i,h)rep(j,w)if(s[i][j]=='S')
        {
            dp[0][0][i][j][0] = 0;
            que.push({0,0,i,j,0});
            dp[i][j][0][0][1] = 0;
            que.push({i,j,0,0,1});
        }

        #define IN(y,x) (0<=y && y<h && 0<=x && x<w)
        int dy[5]={-2,-1,0,1,2};
        int limx[5]={1,2,3,2,1};
        while(!que.empty())
        {
            State n = que.front();
            que.pop();

            // printf(" (%d %d %d %d %d)\n", n.ly,n.lx,n.ry,n.rx,n.LR);

            int sx,sy,mul;
            if(n.LR == 0)
            {
                sx = n.rx;
                sy = n.ry;
                mul = -1;
            }
            else
            {
                sx = n.lx;
                sy = n.ly;
                mul = 1;
            }

            rep(d,5)for(int i=1; i<=limx[d]; ++i)
            {
                int ny = sy+dy[d];
                int nx = sx+mul*i;
                if(IN(ny,nx) && f[ny][nx]!=-1)
                {
                    if(n.LR==0)
                    {
                        if(dp[ny][nx][sy][sx][1] > dp[n.ly][n.lx][n.ry][n.rx][0]+f[ny][nx])
                        {
                            dp[ny][nx][sy][sx][1] = dp[n.ly][n.lx][n.ry][n.rx][0]+f[ny][nx];
                            que.push({ny,nx,sy,sx,1});
                        }
                    }
                    else
                    {
                        if(dp[sy][sx][ny][nx][0] > dp[n.ly][n.lx][n.ry][n.rx][1]+f[ny][nx])
                        {
                            dp[sy][sx][ny][nx][0] = dp[n.ly][n.lx][n.ry][n.rx][1]+f[ny][nx];
                            que.push({sy,sx,ny,nx,0});
                        }
                    }
                }
            }
        }

        int ans = INF;
        rep(i,h)rep(j,w)if(s[i][j]=='T')
        {
            rep(k,h)rep(l,w)
            {
                ans = min(ans,dp[k][l][i][j][0]);
                ans = min(ans,dp[i][j][k][l][1]);
            }
        }
        if(ans == INF) ans = -1;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 28616
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1<<30;
enum mod = 10L^^9 + 7;

void main() {
    string s;
    scan(s);

    if (s.length == 2) {
        writeln(s[0] == s[1] ? "1 2" : "-1 -1");
        return;
    }

    foreach (i ; 0 .. s.length.to!int - 3 + 1) {
        auto t = s[i .. i + 3];
        if (t[0] == t[1] || t[0] == t[2] || t[1] == t[2]) {
            writefln("%d %d", i + 1, i + 3);
            return;
        }
    }

    writeln("-1 -1");
}














































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 508
#include<iostream>
#define INF 10000000
using namespace std;
int main(){
  int n,m,c;
  int dp[50001];
  fill(dp,dp+50001,INF);
  dp[0]=0;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> c;
    for(int i=c;i<=n;i++){
      if(dp[i-c]!=INF){
        dp[i]=min(dp[i-c]+1,dp[i]);
      }
    }
  }
  cout << dp[n]<<endl;
}



Measured memory_bytes: 3296
def solve():
    for i in range(1, n):
        if i == 1:
            dp[i] = abs(lst[i] - lst[i-1]) + dp[i-1]
        else:
            dp[i] = min(abs(lst[i] - lst[i-1]) + dp[i-1], abs(lst[i] - lst[i-2]) + dp[i-2])


inf = 1<<60
n = int(input())
lst = list(map(int, input().split()))
dp = [inf] * (n+1)
dp[0] = 0
solve()
print(dp[n-1])



Measured memory_bytes: 20476
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

#define RG register int

template<typename elemType>
inline void Read(elemType &T){
    elemType X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    T=(w?-X:X);
}

int Pos[200010];
int H,W,N;

int main(){
    Read(H);Read(W);Read(N);
    for(RG i=1;i<=H;++i) Pos[i]=i+1;
    for(RG i=1;i<=N;++i){
        int x,y;Read(x);Read(y);
        Pos[x]=min(Pos[x],y);
    }
    int R=1;
    for(RG i=1;i<=H;++i){
        if(i==H || R>=Pos[i+1]){printf("%d\n",i);break;}
        if(Pos[i+1]!=R+1) ++R;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < (int) n; ++i)
#define ford(i, n) for (int i = ((int) n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"

const int MAXN = 1e5 + 10;
const ll INF = 1e18;

int n, k;
int a[MAXN];
ll s[MAXN];

bool read() {
	if  (scanf("%d%d", &n, &k) < 2) {
		return 0;
	}
	forn(i, n) {
		scanf("%d", &a[i]);
	}
	return 1;
}

void precalc() {
	s[0] = 0;
	forn(i, n) {
		s[i + 1] = s[i] + a[i];
	}
}

ll sum(int l, int r) {
	return s[r + 1] - s[l];
}

ll dp[MAXN];

struct Set {
	multiset<ll> s;
	ll aux{0};

	void insert(ll val) {
		// printf("insert %lld\n", val);
		s.insert(val - aux);
	}

	ll get_max() const {
		if  (s.empty()) {
			return -INF;
		}
		return *s.rbegin() + aux;
	}

	void shift(ll val) {
		// printf("shift %lld\n", val);
		aux += val;
	}
};

ll pref_pos[MAXN];
ll suff_pos[MAXN];

ll solve() {
	precalc();

	Set s;
	forn(i, n + 1) {
		dp[i] = 0;
		if  (i - 1 >= 0) {
			dp[i] = max(dp[i], dp[i - 1]);
			s.shift(a[i - 1]);
			if  (i - k >= 0) {
				s.insert(dp[i - k] + sum(i - k, i - 1));
			}
			dp[i] = max(dp[i], s.get_max());
		}
		// printf("dp[%d] = %lld\n\n", i, dp[i]);
	}

	ll ans = dp[n];

	pref_pos[0] = 0;
	forn(i, n) {
		pref_pos[i + 1] = pref_pos[i] + (a[i] > 0 ? a[i] : 0);
	}

	suff_pos[n] = 0;
	ford(i, n) {
		suff_pos[i] = suff_pos[i + 1] + (a[i] > 0 ? a[i] : 0);
	}

	forn(i, n - k + 1) {
		ll aux = pref_pos[i] + suff_pos[i + k];
		ans = max(ans, max(0ll, sum(i, i + k - 1)) + aux);
	}

	return ans;
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		cout << solve() << endl;
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 8448
def diff(s1, s2):
  count = 0
  for (c1, c2) in zip(s1, s2):
    if c1 != c2:
      count += 1
  return count


def main():
  arr = list(input())
  t01 = (['0', '1'] * len(arr))[:len(arr)]
  t10 = (['1', '0'] * len(arr))[:len(arr)]
  print(min(diff(arr, t01), diff(arr, t10)))


if __name__ == "__main__":
  main()


Measured memory_bytes: 6928
import java.util.Scanner;

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

			int k= sc.nextInt();
			
			int sum = 0;
			
			for(int a = 1 ; a <= k ; a++) {
				for(int b = 1 ; b <= k ; b++ ) {
					for(int c = 1 ; c <= k ; c++ ) {
						
						int gcd1 = gcd(a, b);
						int gcd2 = gcd(gcd1, c);
						
						sum+= gcd2;
					}
				}
			}
			
			System.out.println(sum);
		}
	}
	
	public static int gcd(int a, int b) {

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

}

Measured memory_bytes: 36420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define mii map<pii,ll>
#define mc map<char,ll>
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define M 1000000007


ll power(ll x, ll y)
{ ll res = 1;
  x=x%M;
  while (y > 0)
    {if (y & 1)
      res = (res*x)%M;
     y = y>>1;
     x = (x*x)%M;
    }
    return res;
}

ll prime(ll x)
{ fe(i,2,sqrt(x))
   {if(x%i==0)
    return 0;
   }
return 1;
}


int main()
{ ll t=1;
  //cin>>t;
  while(t--)
  { ll n=0,i=0,j=0,k=0,flag=0,flag1=0;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
  }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int N,ans;
vector<int>A;
void print(const vector<int>&xs){
  for(auto&x:xs)cout<<x<<",";
  cout<<endl;
}
main(){
  cin>>N;
  A=vector<int>(N);
  for(auto&x:A)cin>>x;
  int r=-1;
  vector<int>prev(32),trying;
  for(int l=0;l<N;++l){
    if(r==l-1){
      ++r;
      for(int i=0;i<32;++i){
        prev[i]+=A[r]>>i&1;
      }
    }
    while(true){
      ++r;
      if(r>=N){
        --r;
        break;
      }
      trying=prev;
      for(int i=0;i<32;++i){
        trying[i]+=A[r]>>i&1;
      }
      if(*max_element(trying.begin(),trying.end())>=2){
        --r;
        break;
      }else{
        prev=trying;
      }
    }
    const int f=r-l+1;
    ans+=f;
    for(int i=0;i<32;++i){
      prev[i]-=A[l]>>i&1;
    }
  }
  cout<<ans<<endl;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = unsigned long long int;

int main() {
    lint A;
    double B;
    cin >> A >> B;

    lint X = B * 1000.0;
    X /= 10;
    // cerr << X << endl;
    lint ans = A * X;
    // cerr << ans << endl;
    cout << ans / 100 << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n;
int p[100000 + 5];
//int pos[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        cin >> p[i];
        p[i]--;
        //pos[p[i]] = i;
    }
    rep(i, n - 1) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            cnt++;
        }
    }
    if (p[n - 1] == n - 1) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long h=sc.nextLong();
		long ans=0;
		long t=1;
		while(h>=t){
			ans+=t;
			t*=2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
import sys,gc
    
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),

Measured memory_bytes: 40356
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
while(true)
{
  c = c-b;
  if(c<=0) {cout<<"Yes"<<endl;break;}
  a = a-d;
  if(a<=0) {cout<<"No"<<endl;break;}
  
  
}
}

Measured memory_bytes: 3596
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val otoshidamas = Array(n) {
        readLine()!!.split(" ").let {
            when (it[1]) {
                "JPY" -> Money.JPY(it[0].toInt())
                "BTC" -> Money.BTC(it[0].toDouble())
                else -> error("unknown money type")
            }
        }
    }
    println(otoshidamas.sumByDouble {
        it.toJPY()
    })
}

sealed class Money {
    class JPY(val yen: Int) : Money()
    class BTC(val btc: Double) : Money()

    fun toJPY(): Double = when (this) {
        is JPY -> yen.toDouble()
        is BTC -> btc * 380000
    }
}


Measured memory_bytes: 37864
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


vector<int>TopologicalSort(int n, vector<int>in, vector<int>e[]) {
	stack<int>st;
	for (int i = 0; i < n; i++)if (!in[i])st.push(i);
	vector<int>ret;
	while (st.size()) {
		int i = st.top();
		st.pop();
		ret.pb(i);
		fore(x, e[i]) {
			in[x]--;
			if (!in[x])st.push(x);
		}
	}
	return ret;
}

struct RollingHash {
	vector<ll>hash;
	vector<ll>base_pow;
	ll base, mod;
	const ll DEFAULT_BASE = 1009, DEFAULT_MOD = 1e9 + 7;
	RollingHash(string S = "", ll base_ = -1, ll mod_ = -1) {
		base = (base_ > 0) ? base_ : DEFAULT_BASE;
		mod = (mod_ > 0) ? mod_ : DEFAULT_MOD;
		if (S.size() > 0)initialize(S);
	}
	void initialize(string& S) {
		int N = S.size();
		vector<int>s(N);
		for (int i = 0; i < N; i++)s[i] = S[i];
		initialize2(s);
	}

	void initialize2(vector<int>& S) {
		hash.resize(S.size() + 1);
		base_pow.resize(S.size() + 1);
		hash[0] = 0;
		base_pow[0] = 1;
		for (int i = 1; i <= S.size(); i++) {
			hash[i] = (hash[i - 1]*base + S[i-1]) % mod;
			base_pow[i] = base_pow[i - 1] * base % mod;
		}
	}

	//[a,b)
	ll between(int a,int b) {
		return (mod + hash[b] - hash[a] * base_pow[b - a] % mod)%mod;
	}
};

int dp[1010101];

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

	string S, T;
	cin >> S >> T;
	string temp = S;
	while (S.size() < T.size())S += temp;

	RollingHash rhs1(S+S, 1007, 1e9 + 7);
	RollingHash rht1(T, 1007, 1e9 + 7);


	vector<int>in(S.size());
	vector<int>e[1010101];
	for (int left = 0; left < S.size(); left++) {
		int h1 = rhs1.between(left,left + T.size());
		int h2 = rht1.between(0,T.size());
		if (h1 == h2) {
			in[(left + T.size()) % S.size()]++;
			e[left].pb((left+T.size())%S.size());
		}
	}
	vector<int>ord = TopologicalSort(S.size(),in,e);

	if (ord.size() != S.size()) {
		puts(-1);
		return 0;
	}

	int ans = 0;
	for (int i = 0; i < S.size() - 1; i++) {
		int cur = ord[i];
		fore(to, e[cur]) {
			dp[to] = max(dp[cur] + 1, dp[to]);
			ans = max(dp[to], ans);
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 104040
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Edge {
	int from, to, cost;
	Edge(){}
	Edge(int from, int to, int cost) :from(from), to(to), cost(cost) {}
};
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	vector<Edge>edges(M);
	rep(i, 0, M) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		edges[i].from = a;
		edges[i].to = b;
		edges[i].cost = -c;
	}
	vector<int>d(N, INF);
	d[0] = 0;
	rep(i, 0, N - 1) {
		rep(j, 0, M) {
			Edge e(edges[j]);
			if (d[e.from] == INF)continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
	int ans = -d[N - 1];
 
	vector<int>neg(N, 0);
	rep(i, 0, N) {
		rep(j, 0, M) {
			Edge e(edges[j]);
			if (d[e.from] == INF)continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				neg[e.to] = neg[e.from] = 1;
			}
 
			if (neg[e.from])neg[e.to] = 1;
		}
	}
	if (neg[N - 1])cout << "inf" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> v[101010];
int sz[101010];
bool used[101010];

void szdfs(int x,int p){
    sz[x]=1;
    for(auto to : v[x]){
        if(to==p||used[to])continue;
        szdfs(to,x);
        sz[x]+=sz[to];
    }
}

int centroid(int x,int p,int total){
    for(auto to : v[x]){
        if(to==p||used[to])continue;
        if(2*sz[to]>total)return centroid(to,x,total);
    }
    return x;
}

vector<ll> dist(101010),d[101010];

void dfs(int x,int p){
    rep(i,v[x].size()){
        int to = v[x][i];
        if(to==p||used[to])continue;
        dist[to]=dist[x]+d[x][i];
        dfs(to,x);
    }
}


int main(){
    int n;
    cin>>n;
    rep(i,n-1){
        int x,y,z;
        cin>>x>>y>>z;
        --x;--y;
        v[x].push_back(y);
        v[y].push_back(x);
        d[x].push_back(z);
        d[y].push_back(z);
    }
    szdfs(0,-1);
    int c = centroid(0,-1,sz[0]);
    dfs(c,-1);
    szdfs(c,-1);
    ll ans = 0;
    rep(i,n)ans+=2*dist[i];
    ll mi = inf;
    for(auto to : v[c]){
        if(2*sz[to]==n){
            cout<<ans-dist[to]<<endl;
            return 0;
        }
        else mi=min(mi,dist[to]);

    }
    cout<<ans-mi<<endl;
    return 0;
}

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

string s;

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b, c, d, n;
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;
	int _a = a;
	int _b = b;
	while(a < c){
		if(a + 1 < n && s[a + 1] == '.'){
			a += 1;
		} else if(a + 2 < n && s[a + 2] == '.'){
			a += 2;
		} else {
			cout << "No" << '\n';
			exit(0);
		}
	}
	while(b < d){
		if(b + 1 < n && s[b + 1] == '.'){
			b += 1;
		} else if(b + 2 < n && s[b + 2] == '.'){
			b += 2;
		} else {
			cout << "No" << '\n';
			exit(0);
		}
	}
	a = _a;
	b = _b;
	if(a < b && c > d){
		for(int z = b; z <= d; z++){
			if(z-1 >= 0 && z+1 < n && s.substr(z-1, 3) == "..."){
				cout << "Yes" << '\n';
				exit(0);
			}
		}
		cout << "No" << '\n';
		exit(0);
	} else {
		cout << "Yes" << '\n';
		exit(0);		
	}
}

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

int pow(int k,int n) {
    int s=1;
    for(int i=0;i<n;i++) {
        s*=k;
    }
    return s;
}

pair<int,bool> change3_10(int n,int k) {
    pair<int,bool> a;
    bool f1,f2,f3;
    f1 = f2 = f3 = false;
    for(int m = n, i = 0; i < k; m /= 3, i++)
    {
        switch (m % 3) {
            case 0:
                a.first += pow(10,i) * 3;
                f1 = true;
                break;
            case 1:
                a.first += pow(10,i) * 5;
                f2 = true;
                break;
            case 2:
                a.first += pow(10,i) * 7;
                f3 = true;
                break;
        }
    }
    if (f1 && f2 && f3) {
        a.second = true;
    }
    else {
        a.second = false;
    }
    return a;
}

int main() {
    int n,cnt=0;
    pair<int,bool> a;
    cin >> n;
    for(int i = 5; i <= 20000; i++)
    {
        for(int j = 9; i / pow(3,j) == 0; j--)
        {
            a = change3_10(i,j);
            if (a.second && a.first <= n) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long n,k,cnt;
main()
{
	cin>>n>>k;
	for(long b=k+1;b<=n;b++)
	{
		cnt+=(b-k)*((n+1)/b)-(k==0);
		long B=(n+1)/b*b;
		if(B+k<=n)cnt+=n-(B+k)+1;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
/*
	*	Created By: 'Present_Sir'
	*	Created On: Thursday 27 August 2020 02:48:15 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
            int x,n;
            cin>>x>>n;
            if(n == 0){
                cout<<x<<endl;
                return;
            }
            if(n == 1){
                int t;
                cin>>t;
                if(t == x){
                    cout<<x-1<<endl;
                }else{
                    cout<<x<<endl;
                }
                return;
            }
            multiset < int > s;
            for(int i=0; i<n; ++i){
                int p;
                cin>>p;
                s.insert(p);
            }
            //cout<<x<<endl;
            int lx=x, rx=x;
            auto t = s.find(x);
            if(t == s.end()){
                cout<<x<<endl;
                //cout<<"Kyu?"<<endl;
            }else{
                while(s.find(rx)!=s.end()){
                    ++rx;
                }
                while(s.find(lx)!=s.end()){
                    --lx;
                }
                //cout<<lx<<" "<<rx<<endl;
                if(x-lx == rx-x){
                    cout<<lx<<endl;
                }else{
                    if(x-lx < rx-x){
                        cout<<lx<<endl;
                    }else{
                        cout<<rx<<endl;
                    }
                }
            }
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 105

bool comp(const pair<double,string>& a,const pair<double,string>& b){

    if(a.first == b.first){
        return a.second < b.second;
    }else{
        return a.first > b.first;
    }
}



int main(){

    int n;
    while(cin >> n,n){
        vector<pair<double,string> > vec;
        REP(i,n){
            string str;
            char name[25];
            int p,a,b,c,d,e,f,s,m;
            scanf("%s %d %d %d %d %d %d %d %d %d",name,&p,&a,&b,&c,&d,&e,&f,&s,&m);
            str = name;

            int profit = -p;
            int tm = a+b+c;//葉になるまでの時間
            profit += m*s*f;//m回ごとにf個の実にそれぞれs円で売れる
            REP(j,m){
                tm += (d+e);//m回ごとに葉→花→実になる時間を足す
            }
            vec.push_back({profit/(double)tm,str});
        }
        //ここに降順出力
        sort(vec.begin(),vec.end(),comp);

        REP(j,vec.size()){
            cout << vec[j].second << endl;
        }
        cout << "#" << endl;
        vec.shrink_to_fit();
    }


    return 0;
}


Measured memory_bytes: 3148
w = input()
dic = dict()

while True:
    line = input()
    if line == "END_OF_TEXT":
        break

    for t in line.split():
        dic[t] = dic[t] + 1 if t in dic else 1

ans = 0

for k, v in dic.items():
    if k.lower() == w:
        ans += v

print(ans)



Measured memory_bytes: 5560
S = input()[::-1]
lenS = len(S)
S = list(map(int, list(S)))

cnt = 0
mod = 0

for i in range(lenS - 1):
    v = int(S[i]) + mod
    if v < 5:
        cnt += v
        mod = 0
    elif v == 5:
        cnt += 5
        if S[i + 1] >= 5:
            mod = 1
        else:
            mod = 0
    elif v > 5:
        cnt += 10 - v
        mod = 1

ss = S[-1] + mod
if ss <= 5:
    cnt += ss
    mod = 0
else:
    cnt += 10 - ss
    mod = 1

print(cnt if mod == 0 else cnt + 1)


Measured memory_bytes: 22244
#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;
int main()
{
    long long n,m,a,b,c;

    cin>>n>>m;
if(n==m){
cout<<0;
return 0;
}
if(abs(m)==abs(n))
{
cout<<1;
 return 0;
}
if(n>m&&n<0&&m<0)
{
    n=n*-1;
    b=m*-1;
    cout<<b-n+2;
    return 0;
}
if(n>m&&n>=0&&m<=0 && n>abs(m))
{
    n=n*-1;
    cout<<m-n+1;
    return 0;
}
if(n>m&&n>=0&&m<=0 && n<abs(m))
{
    n=n*-1;
    cout<<abs(m)+n+1;
    return 0;
}
if(n==0 && m>0)
{
    cout<<m-n;
    return 0;
}
if(n<m && m>=0 && n<=0 && abs(n)<m )
{
    n=n*-1;
    cout<<m-n+1;
    return 0;
}
if(n<m && (n>=0 &&m>=0)|| (m<=0 && n<=0))
{
    cout<<m-n;
    return 0;
}
if(n<=0&&m>=0&&abs(n)>m)
{
    m=m*-1;
    cout<<m-n+1;
    return 0;
}
    if(n>m&&n>0&&m>0)//---------------------//
{
    n=n*-1;
    m=m*-1;
    cout<<m-n+2;
    return 0;
}

}


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

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

int main () {
  ll N, M, K;
  std::cin >> N >> M >> K;
  std::vector<ll> A(N, 0);
  std::vector<ll> B(M, 0);
  for (auto& a : A) std::cin >> a;
  for (auto& b : B) std::cin >> b;
  std::vector<ll> csA(N + 1, 0);
  std::vector<ll> csB(M + 1, 0);
  REP1(i, N) csA[i] = csA[i-1] + A[i-1];
  REP1(i, M) csB[i] = csB[i-1] + B[i-1];
  ll result = 0;
  ll j = M;
  REP(i, N+1) {
      if (csA[i] > K) break;
      ll remain = K - csA[i];
      while (csB[j] > remain) --j;
      result = std::max(result, i+j);
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 9592
#include <stdio.h>

int main(void)
{
  int i,l,j,mountain[10],max[3]={0};

  for(i=0;i<10;i++){
    scanf("%d",&mountain[i]);
  }

  for(i=0;i<10;i++){
    for(l=0;l<3;l++){
      if(max[l]<mountain[i]){
	for(j=1;j>=l;j--)
	  max[j+1]=max[j];
	max[l]=mountain[i];
	break;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",max[i]);
  }
  return(0);
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
vector<int> x,y;
const int inf=1e6;
int a[inf],b[inf];
int main(){
	for(int i=1;;i++){
		int p=i*(i+1)*(i+2)/6;
		if(p>=inf) break;
		x.pb(p);
		if(p%2) y.pb(p);
	}
	rep(i,inf) a[i]=b[i]=inf;
	a[0]=0,b[0]=0;
	for(int p:x){
		rep(i,inf-p){
			a[i+p]=min(a[i+p],a[i]+1);
		}
	}
	for(int p:y){
		rep(i,inf-p){
			b[i+p]=min(b[i+p],b[i]+1);
		}
	}
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		cout<<a[n]<<" "<<b[n]<<endl;
	}
}

Measured memory_bytes: 9032
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] chars = sc.next().toCharArray();
        int ans = 0;
        int half = chars.length / 2;
        for (int i = 0; i < half; i++) {
            if (chars[i] != chars[chars.length - i - 1])
                ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long n, i, j, u, v, vis[100001] = {0}, par[100001] = {0}, dp[100001][2] = {0};
vector<long long>adj[100001];

void pardfs(long long x, long long p)
{
	vis[x] = 1;
	par[x] = p;
	for(long long y = 0; y < adj[x].size(); y++)
	{
		if(!vis[adj[x][y]])
		{
			pardfs(adj[x][y], x);
		}
	}
}

void dpdfs(long long x)
{
	vis[x] = 1;
	for(long long y = 0; y < adj[x].size(); y++)
	{
		if(!vis[adj[x][y]])
		{
			dpdfs(adj[x][y]);
		}
	}
	if(adj[x].size() == 1 && x != 1)
	{
		dp[x][0] = dp[x][1] = 1;
	}
	else
	{
		long long m = 1, p = 1;
		for(long long y = 0; y < adj[x].size(); y++)
		{
			if(adj[x][y] != par[x])
			{
				m = ((m % mod) * (dp[adj[x][y]][1] % mod)) % mod;
				p = ((p % mod) * ((dp[adj[x][y]][0] + dp[adj[x][y]][1]) % mod)) % mod;
			} 
		}
		dp[x][0] = m;
		dp[x][1] = p;
	}
}

int main()
{
	cin >> n;
	for(i = 0; i < n - 1; i++)
	{
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	pardfs(1, 0);
	for(i = 0; i <= n; i++)
	{
		vis[i] = 0;
	}
	dpdfs(1);
	if(n == 1)
		cout << 2;
	else
		cout << (dp[1][0] + dp[1][1]) % mod;
	return 0;
}

Measured memory_bytes: 16352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){
    ll n,m;cin>>n>>m;
    if(m%2==1){
        cout<<-1<<endl;return 0;
    }
    vector<ll>v[n];
    rep(i,1,m){
        ll a,b;cin>>a>>b;a--;b--;
        v[a].pb(b);v[b].pb(a);
    }
    queue<ll>q;
    stack<ll>s;
    bool used[n];memset(used,false,sizeof(used));
    ll par[n];
    q.push(0);used[0]=true;
    while(!q.empty()){
        ll t=q.front();q.pop();s.push(t);
        for(auto x:v[t]){
            if(!used[x]){
                q.push(x);
                used[x]=true;
                par[x]=t;
            }
        }
    }
    ll c[n];memset(c,0,sizeof(c));
    vector<l_l>ans;
    memset(used,false,sizeof(used));
    while(!s.empty()){
        ll t=s.top();s.pop();
        if(t==0)break;
        used[t]=true;
        for(auto x:v[t]){
            if(used[x])continue;
            if(c[t]%2==1){
                ans.pb(l_l(t,x));
                c[t]++;
            }else{
                ans.pb(l_l(x,t));
                c[x]++;
            }
        }
    }
    for(auto x:ans){
        cout<<x.first+1<<" "<<x.second+1<<endl;
    }
    return 0;
}







Measured memory_bytes: 11636
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		Long n = Long.parseLong(sc.next());


		String ans = "";
		while(n != 0) {
			char tmp;
			if(n%26 == 0) {
				tmp = 'z';
				n = n/26 -1;
			}else {
				tmp = (char) (n%26 +96);
				n /= 26;

			}

			ans = tmp + ans;

		}
		System.out.println(ans);
	}
}




Measured memory_bytes: 26940
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> p(n);
	rep(i,n) std::cin >> p[i];
	std::vector<int> c;
	c = p;
	std::sort(all(c));
	int diff = 0;
	rep(i,n) {
		if(p[i]!=c[i]) diff++;
	}
	if(diff<=2) {
		print("YES");
		return 0;
	}
	print("NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.*
import kotlin.math.max

fun main() {
    val (n, m) = readInts()

    val neighbors = Array<MutableSet<Int>>(n + 1) { mutableSetOf() }

    repeat(m) {
        val (a, b) = readInts()
        if (b !in neighbors[a]) {
            neighbors[a].add(b)
            neighbors[b].add(a)
        }
    }

    val seen = BooleanArray(n + 1)

    fun bfs(v: Int): Int {
        val queue = LinkedList<Int>()
        queue.add(v)
        seen[v] = true
        var size = 0
        while (queue.isNotEmpty()) {
            val curr = queue.removeFirst()
            size++
            for (u in neighbors[curr]) {
                if (!seen[u]) {
                    seen[u] = true
                    queue.add(u)
                }
            }
        }
        return size
    }

    var ans = 1

    for (i in 1..n) {
        if (neighbors[i].isNotEmpty() && !seen[i]) {
            ans = max(bfs(i), ans)
        }
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 123100