akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;
std::vector<ll> G[5];
bool used[5];

bool dfs( ll v )
{
  used[v] = true;

  if( used[0] && used[1] && used[2] && used[3] )
  {
    puts("YES");

    return true;
  }

  for( auto u : G[v] ) if( !used[u] )
    if( dfs( u ) ) return true;

  used[v] = false;

  return false;
}

int main()
{
  rep( i, 3 )
  {
    int a, b;
    std::cin >> a >> b;

    --a; --b;

    G[a].emplace_back( b );
    G[b].emplace_back( a );
  }

  rep( v, 4 ) 
  {
    bool f = dfs(v);

    if( f )
    {
      return 0;
    }
  }

  puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
inline double sq(double a) { return a*a; }

int N, M, C;
int u[2000], v[2000], w[2000], next[2000], head[200];
int dp[200][1024];

int main() {
    for(;;) {
        scanf("%d%d%d", &N, &M, &C);
        if(N==0) return 0;
        memset(head, -1, sizeof(head));
        rep(i, M) {
            scanf("%d%d%d", u+i, v+i, w+i);
            u[i]--, v[i]--;
            next[i] = head[u[i]];
            head[u[i]] = i;
        }
        typedef pair<int, int> node;
        priority_queue<pair<int, node> > q;
        memset(dp, -1, sizeof(dp));
        q.push(mp(0, mp(0, 0)));
        while(!q.empty()) {
            pair<int, node> vv(q.top());
            q.pop();
            const int cw = -vv.first;
            if(cw>C) break;
            const int cat = vv.second.first;
            const int cdel = vv.second.second;
            if(dp[cat][cdel]!=-1) continue;
            dp[cat][cdel] = cw;
            for(int x=head[cat]; x!=-1; x=next[x]) {
                if(cdel<M) q.push(mp(-cw, mp(v[x], cdel+1)));
                if(dp[v[x]][cdel]==-1) q.push(mp(-cw-w[x], mp(v[x], cdel)));
            }
        }
        rep(i, M+1) if(dp[N-1][i]!=-1 && dp[N-1][i]<=C) {
            printf("%d\n", i);
            break;
        }
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int V, E;
vector<vector<int>> g;
bool visited[110];
bool rec[110];

bool dfs(int u) {
    if (!visited[u]) {
        visited[u] = true;
        rec[u] = true;
        for (int v: g[u]) {
            if (!visited[v] && dfs(v)) return true;
            else if (rec[v]) return true;
        }
    }
    rec[u] = false;
    return false;
}

int main() {
    cin >> V >> E;
    g.resize(V);
    rep(i, E) {
        int s, t; cin >> s >> t;
        g[s].pb(t);
    }

    bool cyclic = false;
    rep(i, V) if (dfs(i)) cyclic = true;
    cout << cyclic << endl;
}




Measured memory_bytes: 3172
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		
		int health1 = scan.nextInt();
		int attack1 = scan.nextInt();
		
		int health2 = scan.nextInt();
		int attack2 = scan.nextInt();
		
		String hantei = "";
		
		for(;;) {
			health2 -= attack1;
			
			if(health1 <= 0 || health2 <= 0) {
				if(health1 <= 0) {
					hantei = "No";
					break;
				}else if(health2 <= 0){
					hantei = "Yes";
					break;
				}
			}
			
			health1 -= attack2;
			
			if(health1 <= 0 || health2 <= 0) {
				if(health1 <= 0) {
					hantei = "No";
					break;
				}else if(health2 <= 0){
					hantei = "Yes";
					break;
				}
			}
		}
		System.out.println(hantei);
		
		scan.close();
	}
}

Measured memory_bytes: 27028
import math
a, b, C = map(float, input().split())
cc = math.sin(math.radians(C))
S = 0.5 * a * b * cc
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
H = S * 2 / a
print(S)
print(L)
print(H)



Measured memory_bytes: 5696
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

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

		int array[] = new int[N];
		for(int i = 0; i < N; i++)array[i] = scanner.nextInt();

		out_put(array);

		int base_value,loc;
		for(int i = 1; i < N; i++){
			base_value = array[i];
			loc = i-1;
			while(loc >= 0 && array[loc] > base_value){
				array[loc+1] = array[loc];
				loc--;
			}
			array[loc+1] = base_value;

			out_put(array);
		}
	}

	private static void out_put(int array[]){

		System.out.printf("%d", array[0]);

		for(int i = 1; i < array.length; i++){
			System.out.printf(" %d", array[i]);
		}
		System.out.printf("\n");
	}
}


Measured memory_bytes: 45144
#include <bits/stdc++.h>
#define ll long long int
#define s second
#define f first
#define pb push_back
#define mk make_pair
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    ll sum=0;
    priority_queue<pair<ll,ll>> pq;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    for(ll i=0;i<n;i++)
    {
        pq.push({arr[i]-arr[i]/2,arr[i]});
    }
    ll dif=0;
    while(m--)
    {
        auto it=pq.top();
        ll x=it.f;
        ll y=it.s;
        dif+=x;
        pq.pop();
        y/=2;
        pq.push({y-y/2,y});
    }
    cout<<sum-dif<<endl;
}

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

#define int long long
#define MAX 110000

signed main(){

  int N, W, H;
  int x, y, w;
  int conw = 0, conh = 0;
  static int aw[MAX], ah[MAX];

  cin>>N>>W>>H;

  for(int i = 0; i < N; i++){
    cin>>x>>y>>w;
    aw[max(x-w,0ll)]++;
    aw[min(W+10,x+w)]--;
    ah[max(y-w,0ll)]++;
    ah[min(H+10,y+w)]--;
  }
  
  for(int i = 0; i < H; i++){
    ah[i+1] += ah[i];
    if(ah[i] <= 0) conh++;
  }
  
  for(int i = 0; i < W; i++){
    aw[i+1] += aw[i];
    if(aw[i] <= 0) conw++;
  }

  if(!conh || !conw) {

    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;

  return 0;
  

  
  return 0;
}



Measured memory_bytes: 4668
import sys

input = sys.stdin.readline

def main():
    while True:
        text = input().rstrip()
        if text == "-":
            break
        n = int(input())
        for i in range(n):
            temp = int(input())
            text = text[temp:] + text[:temp]
        print(text)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5604
#include<stdio.h>

int main(){
    int n,N,A,B,frag = 0,sum = 0;
    scanf("%d %d %d",&N,&A,&B);
    for(int i = 1; i <= N; i++){
        sum = 0;
        n = i;
        while (n > 0) { // n が 0 になるまで
            sum += n % 10;
            n /= 10;
        }
        //sum += (i % 10) + (i % 100) + (i % 1000) + (i % 10000) + (i % 100000);
        if(A <= sum && sum <= B){
            frag += i;
        }
    }
    printf("%d",frag);
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int arv[60] = {c};
    rep(i, 59) arv[i+1] = arv[i] + 60;
    //時刻tで寝ているかどうか判定
    //a分起きてb分寝るので、0 - a, a+b - 2a+b, 2a+2b - 3a+2b...は起きている
    rep(i, 60){
        int awake_beg = 0, awake_fin = a;
        int t = arv[i];
        while(awake_beg <= t){
            if(t <= awake_fin){
                cout << t << endl;
                return 0;
            }
            awake_beg += a+b;
            awake_fin += a+b;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  for (int i = 0; i < s.size(); i++){
    for (int j = 0; j < t.size(); j++){
      if (s[i] == t[j]){
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }
  }
  string ans;
  int i = s.size();
  int j = t.size();
  while (dp[i][j] > 0){
    if (dp[i - 1][j] == dp[i][j]){
      i--;
    } else if (dp[i][j - 1] == dp[i][j]){
      j--;
    } else {
      i--;
      j--;
      ans += s[i];
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans;
}

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

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359



int main() {
	ll N;
	ll sum = 0;
	ll a[100000];
	cin >> N;
	REP(i, N) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			sum += 1;
			if (a[i] % 4 == 0) {
				sum += 1;
			}
		}
	}
	if (sum >= (N / 2)*2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

	
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll res=0;
    for(ll i=2;i*i<=n+5;i++){
        if(n%i==0){
            ll cnt=0;
            while(n%i==0){
                cnt++;
                n/=i;
            }
            ll now=1;
            while(now<=cnt){
                res++;
                cnt-=now;
                now++;
            }
        }
    }
    if(n!=1){
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " ";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int32_t main()
{
	string s,t;
	cin >> s >> t;
	int m = s.size();
	int n = t.size();
	int lcs[m+1][n+1];
	memset(lcs,0,sizeof(lcs));
	for(int i = 1 ; i<=m ; i++){
		for(int j = 1 ; j<=n ; j++){
			if(s[i-1]==t[j-1]){
				lcs[i][j] = lcs[i-1][j-1]+1;
			}
			else{
				lcs[i][j] = max(lcs[i][j-1],lcs[i-1][j]);
			}
		}
	}
	string res = "";
	int i = m;
	int j = n;
	while(i>=1 && j>=1){
		if(s[i-1]==t[j-1]){
			res+=s[i-1];
			j--;
			i--;
		}
		else if(lcs[i-1][j] > lcs[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	reverse(all(res));
	cout << res;
	
	
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

i64 extgcd(i64 a,i64 b,i64 &x,i64 &y){
	i64 d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	} else {
		x=1; y=0;
	}
	return d;
}

i64 mod_inverse(i64 a,i64 m){
	i64 x,y;
	if(extgcd(a,m,x,y)==1) return (x+m)%m;
	return 0;
}

vector<i64> fact;
void init_fact(i64 n,i64 m){
	fact.resize(n+1);
	fact[0]=fact[1]=1;
	for(i64 i=2; i<=n; ++i) fact[i]=(i*fact[i-1])%m;
}


i64 mod_comb(i64 n,i64 k,i64 p){
    if(n<0 or k<0 or n<k) return 0;
	i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    return num*mod_inverse(den,p)%p;
}

void solve(){
    i64 N,A,B,K,mod=998244353;
    cin >> N >> A >> B >> K;

    init_fact(400000,mod);

    i64 ans=0;
    rep(a,0,N+1){
        if((K-a*A)%B) continue;
        i64 b=(K-a*A)/B;
        ans+=mod_comb(N,a,mod)*mod_comb(N,b,mod)%mod;
        ans%=mod;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n;
ll k,a[100005],num[1005],f[1005][2];
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		for(int j=0;j<60;j++)
		  if((1ll<<j)&a[i])
		    num[j]++;
	}
	for(int i=0;i<1000;i++)
	  f[i][0]=f[i][1]=-21474836470000000;
	f[60][1]=0ll;
	for(int i=59;i>=0;i--)
	{
		if(f[i+1][1]>=0)f[i][1]=f[i+1][1]+(((1ll<<i)&k)?n-num[i]:num[i])*(1ll<<i);
		if(f[i+1][0]>=0)f[i][0]=f[i+1][0]+(1ll<<i)*max(n-num[i],num[i]);
		if((1ll<<i)&k)if(f[i+1][1]>=0)f[i][0]=max(f[i][0],f[i+1][1]+(1ll<<i)*num[i]);
	}
	printf("%lld\n",max(f[0][0],f[0][1]));
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (!(H || W)) break;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if ((i + j) % 2 == 0) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3100
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int grp(int x){
  if(x==1||x==3||x==5||x==7||x==8||x==10||x==12) return 1;
  if(x==4||x==6||x==9||x==11) return 2;
  return 3;
}

int main(){
  int x=0,y=0;
  cin >> x >> y;

  if(grp(x)==grp(y)){cout << "Yes" << endl;}
  else{cout << "No" << endl;}

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int ans = 0;
		int A = 0, B = 0;
		boolean minus = true;
		String[] str = new String[N];
		scn.nextLine();
		for(int i = 0;i < N;i++) {
			String buf = scn.nextLine();
			char[] ch = buf.toCharArray();
			boolean isA = false;
			for(int j = 0;j < ch.length;j++) {
				if(j == 0) {
					if(ch[j]=='B')B++;
				}
				if(j == ch.length-1) {
					if(ch[j] == 'A')A++;
					if(B!=A)minus = false;
				}
				if(isA) {
					if(ch[j]=='B') ans++;
				}

				if(ch[j]=='A') {
					isA = true;
				}else {
					isA = false;
				}
			}
		}
		ans+= Math.min(A, B);
		if(minus&&A!=0)ans--;
		System.out.println(ans);

	}

}


Measured memory_bytes: 40476
#include <iostream>

using namespace std;

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    for (int r = 0; r <= M; ++r) {
        for (int g = 0; g <= N; ++g) {
            int b = (N - g) * r + (M - r) * g;

            if (b == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#ABC 049 B - たてなが
H, W = map(int, input().split())
result = [""] * (H*2)
for i in range(H):
    C = input()
    for j in range(W):
        result[2 * i] = C
        result[2 * i + 1] = C
for i in range(H * 2):
    print(result[i])

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

using namespace std;

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end();
#define sz(x) (int)(x).size()
#define FOR_(i, a, b, s) \
  for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define FOR1(n) FOR_(i, 0, n, 1)
#define FOR2(i, n) FOR_(i, 0, n, 1)
#define FOR3(i, a, b) FOR_(i, a, b, 1)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR_, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define each(x, a) for (auto&& x : a)

constexpr int MX = 200005;
constexpr int INF = 1000000202;
constexpr ll LINF = 1000000000000000202LL;
constexpr ll MOD = 1000000007;  // 998244353;
constexpr ld PI = M_PI;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void()
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vt<int> h(n);
  FOR(n) { cin >> h[i]; }
  vt<int> dp(MX, INF);
  dp[0] = 0;
  FOR(n) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << '\n';
  return 0;
}


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

int main() {
	int N, K, x;
	cin >> N >> K;
	int sum = 0;
	for (int i = 0;i < N;i ++) {
		cin >> x;
		if (x < K - x) sum += x + x;
		else sum += K - x + K - x;
	}
	cout << sum;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

この問題は、各y座標に対して独立に考えられる
y座標がiの場所において、ロボットAとBではそれぞれボールの回収に2(x_i)、2(K-x_i)だけかかる
より移動距離が短くなる方のロボットを起動するので、ボールの回収はmin(2x_i, 2(K-x_i))の距離になる
これを全てのy座標に対して計算して総和すれば良い
オーダーはO(N)
*/

Measured memory_bytes: 256
//スマホコーディング
#include<iostream>
#include<algorithm>
#include<vector>;

using namespace std;

int n,m;
int a[100];

int main(){
  cin>>n>>m;
  int odds[2];
  int oddcnt=0;
  for (int i = 0; i < m; i++){
    cin>>a[i];
    if(a[i]&1) {
      oddcnt++;
      if(oddcnt==3){
        cout<<"Impossible"<<endl;
        return 0;
        }else{
        odds[oddcnt-1]=i;
        }
      }
    }
  if(oddcnt>=1) swap(a[0],a[odds[0]]);
  if(oddcnt>=2) swap(a[m-1],a[odds[1]]);
  for(int i = 0; i<m; i++) cout<<a[i]<<(i==n-1?"":" ");
  cout << endl;
  vector<int>b;
  for(int i=0; i< m; i++) {
    if(i==0){
      if(a[i]-1!=0)b.emplace_back(a[i]-1);
    }else if(i==m-1){
      b.emplace_back(a[i]+1);
      }else{
      b.emplace_back(a[i]);
      }
    }
  if(m==1)b.emplace_back(1);
  cout<<b.size()<<endl;
  for(int i=0;i<b.size();i++)cout<<b[i]<<(i==b.size()-1?"":" ");
  cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


char A[1005][1005];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

signed main(){
  int h,w; cin>>h>>w;
  rep(i,h){
    rep(j,w) cin>>A[i][j];
  }
  VVI d(h, VI(w,-1));
  queue<PII> q;

  rep(i,h){ // 黒のマスを全部queueに入れる
    rep(j,w){
      if(A[i][j] == '#'){
        d[i][j] = 0; q.push(PII(i,j));
      }
    }
  }

  // BFS
  while(!q.empty()){ // queueを使うなら必須
    auto now = q.front(); q.pop();
    rep(i,4){ // めっちゃ使う座標の変え方
      int nx = now.first + dx[i];
      int ny = now.second + dy[i];
      if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
      if(d[nx][ny] == -1){
        d[nx][ny] = d[now.first][now.second] + 1;
        q.push(PII(nx,ny));
      }
    }
  }
  int ans = 0;
  rep(i,h){
    rep(j,w) ans = max(ans, d[i][j]);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 13328
#include <cstdio>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
double t[105],v[105];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lf",&t[i]);
    for(int i=1;i<=n;i++)
        scanf("%lf",&v[i]);
    double cur=0,ans=0;
    for(int i=1;i<=n;i++){
        double a=0,b=0,c=0;
        double lim=0x3f3f;
        double tmp=0;
        for(int j=i+1;j<=n+1;j++){
            lim=min(lim, v[j]+tmp);
            tmp+=t[j];
        }
        a=min(min(t[i], v[i]-cur), (-cur+t[i]+lim)*0.5);
        b=max(double(0),cur+a-lim);
        c=t[i]-a-b;
        ans+=0.5*(cur*2+a)*a;
        ans+=(cur+a)*c;
        ans+=0.5*((cur+a)*2-b)*b;
        cur+=a;
        cur-=b;
    }
    printf("%lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
 
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for(int i = x; i < n; i++)

int N;
vector<int> a;
int odd = 0, even = 0;

int main()
{
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        int t;
        cin >> t;
        t = t%2;
        if (t) odd++;
        else   even++;
        a.push_back(t);
    }
    if (odd%2==0)
    {
        cout <<"YES";
    }
    else
    {
        cout <<"NO";
    }
    return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<vector>
#include<map>


using namespace std;
using ll=long long;
using vll=vector<ll>;
using mii=map<int,int>;


int main(void)
{
	int n;
	ll m;

	while(scanf("%d%lld", &n, &m)==2)
	{
		vll a(n+1);
		vll s(n+1);
		mii c;

		for(int i=1;i<=n;i++)
		{
			scanf("%lld", &a[i]);
			s[i]=s[i-1]+a[i];
			c[s[i]%m]++;
		}

		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			int idx=s[i-1]%m;
			if(c.find(idx)!=c.end())
			{
				ans+=c[idx];
//				printf("Hit! : c[%d]=%lld\n", idx, c[idx]);
			}
			else
			{
//				printf("Miss : idx=%d\n", idx);
			}
//for(auto&mc:c) printf("%d : %d\n", mc.first, mc.second);
			auto it=c.find(s[i]%m);
			(it->second)--;
			if(it->second==0) c.erase(it);

		}
		printf("%lld\n", ans);
	}

	return 0;
}


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

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

    string s;
    cin >> s;

    int n = s.size();
    for(int i = 0; i < n; i++){
        cout << 'x';
    }
}



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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    ll a,b;
    cin >> a >> b;

    ll m,n;
    if(a==0){
        m=a;
    }else{
        a--;
        ll ad = a/2;
        if(ad%2==0){
            ad = 0;
        }else{
            ad = 1;
        }
        if(a%2==0){
            m = a^ad;
        }else{
            m = 1^ad;
        }
    }


    ll bd = b/2;
    if(bd%2==0){
        bd = 0;
    }else{
        bd = 1;
    }
    if(b%2==0){
        n = b^bd;
    }else{
        n = 1^bd;
    }

    ll ans = m^n;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        }
}

Measured memory_bytes: 26316
#include <iostream>
using namespace std;
static const int MAX = 100;

int BubbleSort(int* A, int n) {
    int flag = 1;
    int temp, count = 0;
    while (flag) {
        flag = 0;
        for(int j = n-1; j >= 1; --j) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = 1;
                count++;
            }
        }
    }
    return count;
}

int main(int argc, char const *argv[]) {
    int A[MAX];
    int n, count;
    //??\???????????°???????´?
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    count = BubbleSort(A, n);

    cout << A[0];
    for(int i = 1; i < n; ++i) {
        cout << " " << A[i] << flush;
    }
    cout << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3100
package main

import "fmt"

func abs_sum(input []int) int{
	var ans int
	for i := range input {
		if input[i] > 0 {
			ans += input[i]
		} else {
			ans -= input[i]
		}
	}
	return ans
}

func merge(left, right []int) (ret []int) {
	ret = []int{}
	for len(left) > 0 && len(right) > 0 {
		var x int
		if right[0] > left[0] {
			x, left = left[0], left[1:]
		} else {
			x, right = right[0], right[1:]
		}
		ret = append(ret, x)
	}
	ret = append(ret, left...)
	ret = append(ret, right...)
	return
}

func sort(left, right []int) (ret []int) {
	if len(left) > 1 {
		l, r := split(left)
		left = sort(l, r)
	}
	if len(right) > 1 {
		l, r := split(right)
		right = sort(l, r)
	}

	ret = merge(left, right)
	return
}

func split(values []int) (left, right []int) {
	left = values[:len(values) / 2]
	right = values[len(values) / 2:]
	return
}

func Sort(values []int) (ret []int) {
	left, right := split(values)
	ret = sort(left, right)
	return
}

func main(){
	var n int
	fmt.Scanf("%d",&n)
	a := make([]int,n)
	for i := range a {
		var b int
		fmt.Scanf("%d",&b)
		a[i] = b - i - 1
	}

	c := Sort(a)

	result := make([]int,n)
	for i := range result {
		result[i] = c[i]-c[n/2]
	}

	fmt.Println(abs_sum(result))
}

Measured memory_bytes: 15744
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _n = get!(usize);
    let mut aa = get!(String).split_whitespace().map(|a| a.parse::<i32>().unwrap()).collect::<Vec<_>>();

    let mut c = 0;
    loop {
        for a in aa.iter() {
            if a%2 == 1 {
                println!("{}", c);
                return;
            }
        }
        c += 1;
        let bb = aa.into_iter().map(|a| a/2).collect();
        aa = bb;
    }
}

Measured memory_bytes: 2132
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    for(i in 1..n){
        a[i-1] = a[i-1] - i
    }
    a.sort()
    val median = a[(n+1)/2 - 1]
    var ans = 0L
    for(i in 0 until n){
        ans += Math.abs(a[i] - median)
    }
    println(ans)
}

Measured memory_bytes: 80716
def larger(x, y):
	if x > y: return x
	return y

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

dp1 = []
dp2 = []
x = 0
for i in range(0, N):
	x += A1[i]
	dp1.append(x)
dp2.append(dp1[0]+A2[0])
for i in range(1, N):
	dp2.append(larger(dp2[-1], dp1[i])+A2[i])
print(dp2[N-1])

Measured memory_bytes: 38384
#include <iostream>
#include <string>
 
int main()
{
    size_t K;
    std::string S;
 
    std::cin >> K >> S;
 
    const size_t length = S.length();
    if (length <= K)
    {
        std::cout << S << std::endl;
    }
    else
    {
        std::cout << S.substr(0, K) << "..." << std::endl;
    }
 
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#define llint long long

using namespace std;

llint N, K;
llint cnt[100005];

int main(void)
{
	cin >> N >> K;
	
	int a, b;
	for(int i = 0; i < N; i++){
		cin >> a >> b;
		cnt[a] += b;
	}
	
	llint sum = 0;
	for(int i = 1; i <= 100005; i++){
		sum += cnt[i];
		if(sum >= K){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long prod = 1;
    for (int i = 0; i < n; i++)
    {
        long double num;
        cin >> num;
        if (num == 0)
        {
            prod = 0;
            break;
        }
        else if (num > ((long double) 1e18 / prod))
        {
            prod = -1;
        }
        else
        {
            prod *= num;
        }
    }
    cout << prod << endl;
}

Measured memory_bytes: 3768
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int x = 0, y = 0;
    int t = 0;

    bool ok = true;
    for (int i = 0; i < n; ++i) {
        int nt, nx, ny;
        cin >> nt >> nx >> ny;

        int dis = abs(x - nx) + abs(y - ny);
        if (dis > nt - t) {
            ok = false;
        }
        if ((dis ^ (nt - t)) & 1) {
            ok = false;
        }
        t = nt, x = nx, y = ny;
    }

    if (ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



struct Edge{
  ll to;
  ll cost;
};

vector<ll> bellman_ford(vector<vector<Edge>>& edges){
  ll n = edges.size();
  vector<ll> d(n, 1e10);
  vector<ll> upd(n, 0);
  d[0] = 0;
  rep(times, 2*n){
    rep(from, n){
      for(auto e : edges[from]){
        if(d[from] == 1e10) continue;
        if(d[from] + e.cost < d[e.to]){
          d[e.to] = d[from] + e.cost;
          if(d[from] == -1e10) d[e.to] = -1e10;
          if(n-1 <= times)     d[e.to] = -1e10;
        }
      }
    }
  }
  
  return d;
}

int main(){
  ll n, m, p;
  cin >> n >> m >> p;
  vector<ll> a(m);
  vector<ll> b(m);
  vector<ll> c(m);
  rep(i, m) cin >> a[i] >> b[i] >> c[i];
  rep(i, m) a[i]--, b[i]--;
 
  vector<vector<Edge>> g(n, vector<Edge>());
  rep(i, m) g[a[i]].push_back({b[i], -c[i]+p});

  vector<ll> d = bellman_ford(g);

  if(d[n-1] <= -1e10) cout << -1 << endl;
  else                cout << max(0ll, -d[n-1]) << endl;



  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << max(A+B, max(A-B, A*B)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n; cin >> n;
    vint a(n);
    int sum=0;
    rep(i,n){
        cin >> a[i];
        sum^=a[i];
    }

    rep(i,n){
        int res=sum^a[i];
        cout<<res<<' ';
    }
    
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
int main(){


    string s,s1;
    cin>>s>>s1;
    int l=s1.size();
    int i,c=0;
    for(i=0;i<l-1;i++){

        if(s.at(i)!=s1.at(i)){
            c++;
            break;
        }

    }
    if(c==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}


Measured memory_bytes: 3628
#include <stdio.h>
int main(int argc, char const *argv[]) {
 int w, h, x, y, r;
 int x_max , x_min, y_max, y_min;
 scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
 x_max = x + r;
 x_min = x - r;
 y_max = y + r;
 y_min = y - r;
 if (x_max > w || x_min < 0 || y_max > h || y_min < 0) {
  printf("No\n");
 } else {
  printf("Yes\n");
 }
 return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include <iterator>
#include <cassert>

using namespace std;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;

ll LONG_LONG_MAX = 1e18;



/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/



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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

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

    if (sc.next().equals("+")) {
      System.out.println(a + sc.nextInt());
    } else {
      System.out.println(a - sc.nextInt());
    }
    
  }
}

Measured memory_bytes: 35664
l=list(map(int,input().split()))
ans=0
l.sort()
#print(l)
if (l[1]-l[0])%2!=0:#最小と真ん中の値を偶数差にする
    l[1]+=1
    l[2]+=1
    ans+=1
#print(l)
x=(l[1]-l[0])//2#l[0]を2足す回数
l[0]+=(2*x)
ans+=x
#print(l)
y=(l[2]-l[1])
ans+=y
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

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

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

typedef long long ll;

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

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

int main() {
//	INPUT();
	OUTPUT();
    int n , x;
    string str;
    cin>>n;
    map <string,int> mp;
    for(int i = 0 ; i < n ; i++){
        cin>>str;
        mp[str]++;
    }
    
    cout<<"AC x "<<mp["AC"]<<el;

    cout<<"WA x "<<mp["WA"]<<el;

    cout<<"TLE x "<<mp["TLE"]<<el;

    cout<<"RE x "<<mp["RE"]<<el;




	return 0;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;

  vector<int> a(n), b(n), c(n);
  vector<vector<int>> dp(n + 1, vector<int>(3));

  REP(i, n) {
    cin >> a[i] >> b[i] >> c[i];
  }

  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;

  REP(i, n) {
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
  }

  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 6912
#include<iostream>
using namespace std;
signed main(){
  int n,m,c=0;
  cin>>n>>m;
  int a[110][110],b[100];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){     
      cin>>a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      c+=a[i][j]*b[j];
    }
    cout<<c<<'\n';
    c=0;
  }
  return(0);
}



Measured memory_bytes: 3144
#include<stdio.h>
#include<math.h>
int main()
{
unsigned long a,b,c,i,min;
scanf("%ld",&a);
min=a;
for(i=1;i<=sqrt(a);i++){
if((a%i)==0){
b=a/i;
c=i+b-2;
if(min>c){
min=c;
}
}
}
printf("%ld\n",min);
return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  if (N==1) {
    cout << "Hello World\n";
  } else if (N==2) {
    int A, B;
    cin >> A >> B;
    cout << A+B << '\n';
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.find("mw")!=string::npos||s.find("wm")!=string::npos||s.find("ee")!=string::npos)cout<<"Rabbit"<<endl;
  else cout<<"Cat"<<endl;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
	ll k, t;
    cin >> k >> t;
    vll a(t);
    REP(i, t) cin >> a[i];
    VSORT(a);
    ll ans = max((2 * a[t - 1] - k - 1), (ll)0);
    cout << ans << endl;
    return 0;
}

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

int getdigit(int x){
	int t=x,ret=0;
	while(t){
		ret++;
		t/=10;
	}
	return ret;
}

int cf(int x,int z){
	int ret=1;
	for(register int i=1;i<=z;i++){
		ret*=x;
	}
	return ret;
}

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int t1=getdigit(b);
	int t2=cf(10,t1);
	int c=a*t2+b;
	//printf("%d %d %d\n",t1,t2,c);
	for(register int i=1;i<=1000;i++){
		if(i*i==c){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    //page
    int a = sc.nextInt();
    
    int print = a/2;
    
    
    if(a%2!=0){
      print++;
    }
    
    System.out.println(print);
    
  }
}

Measured memory_bytes: 21460