akhauriyash/Code-Regression huggingface dataset:
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(long[]);

  foreach (i; 1 .. n)
    a[i] = a[i] + a[i - 1];
  long mn = 10L ^^ 18;
  import std.math;

  foreach (i; 0 .. (n - 1)) { // [0, i], (i, n)
    mn = min(mn, abs(a[i] - (a[n - 1] - a[i])));
  }
  writeln(mn);
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

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

  if (a%3==0 || b%3==0 || (a+b)%3==0)
    cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


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

#define MAXN (200010)

char s[MAXN], t[MAXN];
int cnt1[26], cnt2[26];

int main() {
    scanf("%s", s);
    scanf("%s", t);
    for (int i = 0; s[i]; ++i) {
        cnt1[s[i] - 'a']++;
        cnt2[t[i] - 'a']++;
    }
    std::sort(cnt1, cnt1 + 26);
    std::sort(cnt2, cnt2 + 26);
    for (int j = 0; j < 26; ++j) {
        if (cnt1[j] != cnt2[j]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
z = int(input())
l = []
for i in range(1,10):
    l.append(i)
    for j in range(max(0,i-1),min(10,i+2)):
        l.append(int(str(i)+str(j)))
        for k in range(max(j-1,0),min(10,j+2)):
            l.append(int(str(i)+str(j)+str(k)))
            for m in range(max(k-1,0),min(10,k+2)):
                l.append(int(str(i)+str(j)+str(k)+str(m)))
                for n in range(max(m-1,0),min(10,m+2)):
                    l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)))
                    for o in range(max(n-1,0),min(10,n+2)):
                        l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)))
                        for p in range(max(o-1,0),min(10,o+2)):
                            l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)))
                            for q in range(max(p-1,0),min(10,p+2)):
                                l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)))
                                for r in range(max(q-1,0),min(10,q+2)):
                                    l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)+str(r)))
                                    for s in range(max(r-1,0),min(10,r+2)):
                                        l.append(int(str(i)+str(j)+str(k)+str(m)+str(n)+str(o)+str(p)+str(q)+str(r)+str(s)))

l.sort()
print(l[z-1])

Measured memory_bytes: 11424
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int N;
void Qt(int l,int r){
  cout << "?" << " ";
  if(r>l)rep(i,l,r)cout << i << " ";
  else{
    rep(i,l,2*N+1)cout << i << " ";
    rep(i,1,r)cout << i << " ";
  }
}
int main(){
  lli C,D,E,F,/*N,*/M,K,L,R,X,Y,Z,H,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  Vec(W,bool,N,0);
  Vec(P,int,N,0);
  rep(i,0,M){
    cin >> C >> S;
    if(W[C-1]==false){
      if(S=="AC"){
        W[C-1]=true;
        sum++;
        }
      else P[C-1]++;
      }
    }
  rep(i,0,N)if(W[i]==true)num+=P[i];
  cout << sum << " " << num << endl;
  }
      
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
map<lli,int>prime_factor(lli n){
  map<lli,int>res;
  for(lli i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  map<int,int>P;
  rep(i,0,N){
    cin >> A;
    P[A]=i+1;
  }
  for(auto v:P)Out(v.second);
}

Measured memory_bytes: 5504
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[31][65536];
int c[30];
int d[30];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<31;i++)
			for(int j=0;j<65536;j++)dp[i][j]=-99999999;
		dp[0][0]=0;
		for(int i=0;i<30;i++)c[i]=d[i]=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<16;j++){
				int t;
				scanf("%d",&t);
				c[i]+=(t<<j);
			}
		}
		for(int i=0;i<b;i++){
			for(int j=0;j<16;j++){
				int t;
				scanf("%d",&t);
				d[i]+=(t<<j);
			}
		}
		for(int i=0;i<a;i++){
			for(int j=0;j<65536;j++){
				if(dp[i][j]<0)continue;
				for(int k=0;k<b;k++){
					int C=(j|c[i])&d[k];
					int V=0;
					for(int l=0;l<16;l++)if((1<<l)&C)V++;
					dp[i+1][(j|c[i])-C]=max(dp[i][j]+V,dp[i+1][(j|c[i])-C]);
				}
			}
		}
		int ret=0;
		for(int i=0;i<65536;i++)ret=max(ret,dp[a][i]);
		printf("%d\n",ret);
	}
}

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

int main()
{
    int n;
    cin>>n;
    vector<double> p(n+1);
    for(int i=1; i<=n; i++)
        cin>>p[i];
    vector<vector<double> > dp(n+1, vector<double> (n+1,0.0)); // dp[i][j] ----> total i coins out of which j are heads up.
    dp[0][0] = 1.0;
    for(int i=1; i<=n; i++)
        for(int j=0; j<=i; j++)
    {
        if(j==0)
            dp[i][j]+= dp[i-1][j] * (1-p[i]);
        else{
            dp[i][j]+= dp[i-1][j] * (1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }

    double sum = 0.0;
    for(int i = (n-1)/2 + 1; i<=n; i++)
        sum+=dp[n][i];

    cout<< setprecision(16) << fixed<<sum;
    return 0;
}


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

using namespace std;

int main() {
  int n; cin >> n;
  int mx1, mx2, mn1, mn2;
  mx1 = mx2 = INT_MIN; mn1 = mn2 = INT_MAX;
  //cout << mx << " " << mn;
  for(int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    mx1 = max(mx1, x + y);
    mn1 = min(mn1, x + y);
    mx2 = max(mx2, x - y);
    mn2 = min(mn2, x - y);
  }
  cout << max(abs(mx1 - mn1), abs(mx2 - mn2));
  return 0;
}

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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 1000000000000000000

int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	ll z = k;
	if (x / d >= k) cout << x - (k * d);
	else {
		k = x / d;
		x = x % d;
		z -= k;
		//cout << z << endl;

		if (z % 2 == 0) cout << x;
		else cout << abs(x - d);
	}
}

Measured memory_bytes: 3528
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",&s);
  int max = 0,ans = 0;
  for(int i = 0;i < n;i++){
    if(s[i] == 'I'){
      ans++;
    }else{
      ans--;
    }
    if(ans > max){
      max = ans;
    }
  }
  printf("%d",max);
  return 0;
}

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

int main()
{
int N , M ,ans ,i;
cin >> N >> M  ;

int A[M];

for(i=0;i<M;i++){
  cin >> A[i] ;
}

ans = 0 ;

for(i=0;i<M;i++){
  ans += A[i] ;
}


if((N-ans)>=0)
cout << N-ans ;
else
cout << "-1";

return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
vector<vector<int>>to(100010);
int dist[100010];

int dfs(int now){

    if(dist[now]!=-1)return dist[now];

    int ret=0;
    for(auto cand:to[now]){
        ret=max(ret,dfs(cand)+1);
    }
    //if(ret==0)ret=path;

    return dist[now]=ret;
}




int main(){

    int n,m;
    cin>>n>>m;
    
    int cnt[n]={};
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        to[x].emplace_back(y);
        //cnt[x]++;
    }
    /*
    vector<int>start;
    rep(i,n){
        if(cnt[i]==0)start.emplace_back(i);
    }
    int ans=0;
    */
    rep(i,n)dist[i]=-1;
    int ans=0;
    rep(i,n){
    ans=max(ans,dfs(i));
    }
    cout<<ans<<endl;


    return 0;

}
/*


*/


Measured memory_bytes: 8576
using System;
using System.Linq;
using System.Collections.Generic;


namespace Test1 {

    


    class ClassMain {


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n1 = ints[0];
                int n2 = ints[1];
                if (n1 == 0 && n2 == 0) { break; }

                List<int> n1s = new List<int>();
                List<int> n2s = new List<int>();

                if (n1 > 0) {
                    n1s = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                }
                if (n2 > 0) {
                    n2s = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                }
                n1s.AddRange(n2s);

                n1s.Sort();
                int max = n1s.ElementAt(0);
                for (int i = 0; i < n1s.Count - 1; i++) {
                    int diff = n1s.ElementAt(i + 1) - n1s.ElementAt(i);
                    max = Math.Max(max, diff);
                }
                
                Console.WriteLine(max);
            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 12248
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto g=new int[][](n+1, 0);
  auto can=new int[](n+1);

  void f(int i){
    if(g[i].length==0){can[i]=0; return;}
    foreach(j; g[i]) f(j);
    foreach(j; g[i])if(can[j]==0){
      can[i]=can[j]=1; break;
    }
    can[i]=max(can[i], 0);
  }

  foreach(i; 1..n+1){
    int p; rd(p);
    g[p]~=i;
    fill(can, -1);
    f(0);
    int sm=reduce!("a+max(0, b)")(0, can);
    // assert(sm%2==0);
    writeln(sm/2);
    // writeln(can);
  }

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 2680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  string s;
  cin >> s;

  if (s.size() == 0) {
    cout << 0 << endl;
    return 0;
  }

  string s1 = "", s2 = "";
  char z = '0', b = '1';
  bool flag = true;
  for (int i = 0; i < s.size(); ++i) {
    if (flag) {
      s1 += z;
      s2 += b;
    } else {
      s1 += b;
      s2 += z;
    }
    flag = !flag;
  }

  ll ans1 = 0, ans2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != s1[i]) {
      ans1 += 1;
    }
    if (s[i] != s2[i]) {
      ans2 += 1;
    }
  }

  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 768
import sys

input = sys.stdin.readline

S = input().strip()

ans = 'Yes'
for i in range(len(S)):
	char = S[i]
	if (i+1)%2==1:
		if char=='L':
			ans = 'No'
			break
	else:
		if char=='R':
			ans = 'No'
			break

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  int n,ans=-1e9;cin>>n;
  vector<vector<bool>> f(n,vector<bool>(10,0));
  REP(i,n) REP(j,10){
    bool t;cin>>t;
    if(t) f.at(i).at(j)=1;
  }
  vector<vector<int>> p(n,vector<int>(11));
  REP(i,n) REP(j,11) cin>>p.at(i).at(j);
  
  for(int i=1;i<=1023;i++){
    int profit=0;
    REP(k,n){
      int count=0;
      REP(j,10){
        if((i&(1<<j)) && f.at(k).at(9-j)) count++; 
      }
      profit+=p.at(k).at(count);
    }
    ans=max(ans,profit);
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    string str[n],s;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
    }
    sort(str,str+n);
    for(int i=0;i<n;i++)
    {
        s+=str[i];
    }
    cout<<s<<endl;
    return 0;
}


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

using namespace std;

int main() {
    string x;
    cin>>x;
    vector < int > v[26];
    for(int i=0;i<x.size();i++){
        v[x[i]-'a'].push_back(i);
    }
    for(int i=0;i<26;i++){
        if(v[i].size()<=1)
            continue;
        for(int j=0;j<v[i].size()-1;j++){
            if(v[i][j+1]-v[i][j]<=2){
                cout<<v[i][j]+1<<' '<<v[i][j+1]+1<<endl;
                return 0;
            }
        }
    }

    cout<<-1<<' '<<-1;
    cout<<endl;
    return 0;
}


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

using namespace std;
int main(){
int n;
 cin>>n;


vector<string>vect(n);

map<string,int>mp;

  int M=0;

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

mp[vect[i]]++;

}

for(auto m:mp){

M=max(M,m.second);

}

for(auto i :mp){

if(i.second==M){
        cout<<i.first<<endl;

    }

}

}

Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
using namespace std;
int N,L;
int main(){
    cin >> N >> L;
    int sum = 0;
    for(int i =1;i<=N;i++){
            sum +=  L + i -1;
    }  
    if(1-L<=0){
        sum = sum - (L + 1 -1);
    }else if(1-L>=N){
        sum = sum - (L + N -1);
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 3740
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 25;
string grid[mxn];
int vis[mxn][mxn];
int n,m;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
int ans[mxn][mxn];

bool valid(int x, int y){
	return (x>=0 and x<n and y>=0 and y<m);
}



int32_t main(){
	NINJA;

	cin >> n >> m;
	fo(i,n) cin >> grid[i];

	int x=-1,y=-1;
	fo(i,n){
		fo(j,n){
			if(grid[i][j]=='.'){
				x=i,y=j;
				break;
			}
		}
		if(x!=-1) break;
	}

	int res =0 ;
	fo(x,n){
		fo(y,m){
			if(grid[x][y]=='#') continue;
			memo(vis,-1);
			vis[x][y]=0;
			int se,ed;
			queue<pair<int,int>> q;
			q.push({x,y});

			while(!q.empty()){
				tie(se,ed) = q.front();
				q.pop();
				fo(i,4){
					int nx=se+dx[i];
					int ny=ed+dy[i];
					if(valid(nx,ny) and vis[nx][ny]==-1 and grid[nx][ny]=='.'){
						vis[nx][ny] = 1 + vis[se][ed];
						ans[nx][ny] = max(ans[nx][ny],vis[nx][ny]);
						q.push({nx,ny});
					}
				}
			}
		}
	}

	fo(i,n){
		fo(j,m){
			res=max(res,ans[i][j]);
		}
	}

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 3600
INTEGER N,M
INTEGER,ALLOCATABLE,DIMENSION(:)::ANSWER
INTEGER A,B
READ*,N,M
ALLOCATE(ANSWER(N))
ANSWER=0
DO I=1,M
  READ*,A,B
  ANSWER(A)=ANSWER(A)+1
  ANSWER(B)=ANSWER(B)+1
END DO
PRINT"(I0)",ANSWER
END

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vec arr (n);
    vec dp (n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < n; i++){
        int indx;
        if (abs(arr[i] - arr[i-1]) + dp[i-1] < abs(arr[i]- arr[i-2]) + dp[i-2]){
            indx = i-1;
        }
        else{
            indx = i-2;
        }
        dp[i] = abs(arr[i] - arr[indx]) + dp[indx];
    }
    // for (auto i: dp){
    //     cts(i);
    // }
    ctn(dp[n-1]);
    return 0;
}


Measured memory_bytes: 3984
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
vector<int> G[100010];
int ans;
int flag = 0;
int used[100010] = {0};
int k;
void dfs(int n){
    if(n == 0){
        used[0] = 1;
        ans = k;
        int cnt = 0;
        for(auto x:G[n]){
            if(used[x] == 0){
                ans *= max(k-1-cnt,0LL);
                ans %= MOD;
                cnt++;
                used[x] = 1;
                dfs(x);
            }
        }
    }
        int cnt = 0;
        for(auto x:G[n]){
            if(used[x] == 0){
                ans *= max(k-2-cnt,0LL);
                ans %= MOD;
                cnt++;
                used[x] = 1;
                dfs(x);
            }
        }
}
signed main(){
    int n;
    cin >> n >> k;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1);
        G[b-1].pb(a-1);
    }

    dfs(0);
    cout << ans%MOD << endl;

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc133.contest.atcoder.jp/tasks/abc133_b

Measured memory_bytes: 9984
n, k = map(int, input().split())
*x, = map(int, input().split())
 
ans = float("inf")
for i in range(n-k+1):
    l, r = x[i], x[i+k-1]
    ans = min(ans, min(abs(l), abs(r)) + r - l)
 
print(ans)

Measured memory_bytes: 14252
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,m = LI()
    route = [[] for _ in range(n+1)]
    for _ in range(m):
        a,b = LI()
        route[a].append(b)
        route[b].append(a)
    ans = False

    for i in route[n]:
        if 1 in route[i]:
            ans = True
    print("POSSIBLE" if ans else "IMPOSSIBLE")
        

main()            


Measured memory_bytes: 108836
#include <stdio.h>
#include <math.h>

int main() {
	long int i, j, N, K, cont = 0;
	double a, sum = 0;

	scanf("%d %d", &N, &K);

	for (i = 1; i <= N; i++) {
		cont = 0;
		for (j = i; j < K; j *= 2)cont++;
		a = ((double)1 / (double)N) * pow(0.5, (double)cont);
		sum += a;
	}

	printf("%.12lf\n", sum);
	
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;
using System.Reflection;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] nw = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nw[0];
            int W = nw[1];

            var ls = new List<MyClass>();
            for (int i = 0; i < n; i++)
            {
                var input = ReadLine().Split(' ').Select(long.Parse).ToArray();
                ls.Add(new MyClass(input[0], input[1]));
            }
            long[,] dp = new long[n+1, W+1];

            for (int i = 0; i < n; i++)
            {
                for (int w = 0; w <= W; w++)
                {
                    if (w >= ls[i].weight)
                    {
                        dp[i + 1, w] = Max(dp[i, w - ls[i].weight] + ls[i].value, dp[i, w]);
                    }
                    else dp[i + 1, w] = dp[i, w];
                }
            }
            WriteLine(dp[n, W]);
        }

        class MyClass
        {
            public MyClass(long weight,long value)
            {
                this.weight = weight;
                this.value = value;
            }

            public long weight { get; set; }
            public long value { get; set; }
        }
    }
}

Measured memory_bytes: 90976
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x; cin >> x;
	int ans = 2*(x / 11);
	if ((x%11) >= 7)ans += 2;
	else if((x%11)!=0)ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int QX[10202]={0};
int QY[10202]={0};
const int X[4]={0,1,0,-1};
const int Y[4]={1,0,-1,0};
int main(){
  int w,h,sx,sy,gy,gx,c,d,x,y,n;
  int i,q,r,a,j;
  while(1){
    scanf("%d %d",&w,&h);
    if(w==0&&h==0)break;
    int m[102][102]={{0}};
    scanf("%d %d",&sx,&sy);
    scanf("%d %d",&gx,&gy);
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&c,&d,&x,&y);
      m[y][x]=m[y+1][x]=m[y][x+1]=m[y+1][x+1]=c;
      if(d==0)x+=2;
      else    y+=2;
      m[y][x]=m[y+1][x]=m[y][x+1]=m[y+1][x+1]=c;
    }
    a=0;
    if(m[sy][sx]==m[gy][gx]){
      q=0;
      c=m[sy][sx];
      QY[0]=sy;
      QX[0]=sx;
      r=1;
      m[sy][sx]=0;
      while(q!=r){
	for(i=0;i<4;i++){
	  if(m[QY[q]+Y[i]][QX[q]+X[i]]==c){
	    if(QY[q]+Y[i]==gy&&QX[q]+X[i]==gx){
	      a=1;
	      break;
	    }
	    QY[r]=QY[q]+Y[i];
	    QX[r]=QX[q]+X[i];
	    m[QY[q]+Y[i]][QX[q]+X[i]]=0;
	    r++;
	  }
	}
	if(a)break;
	q++;
      }
    }
    if(a)printf("OK\n");
    else printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  double x,y;
  double rad;
  int run;
  int shita;
  x = y = 0;
  rad = M_PI / 2;
  
  for(;;){
    scanf("%d,%d",&run,&shita);
    if(run == 0 && shita == 0){break;}
    
    x += cos(rad) * run;
    y += sin(rad) * run;
    
    rad -= shita / 180.0 * M_PI;
  }
  
  modf(x, &x);
  modf(y, &y);
  printf("%.0lf\n%.0lf\n",x,y);
  
  return 0;
  
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[][] mise = new int[n][10];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 10; j++) {
					mise[i][j] = in.nextInt();
				}
			}

			int[][] p = new int[n][11];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 11; j++) {
					p[i][j] = in.nextInt();
				}
			}

			long ans = -INF;
			for (int i = 1; i < (1 << 10); i++) {
				long tmp = 0;
				for (int k = 0; k < n; k++) {
					int c = 0;
					for (int j = 0; j < 10; j++) {
						if (((i >> j) & 1) == 1 && 1 == mise[k][j]) {
							c++;
						}
					}
					tmp += p[k][c];
				}
				ans = Math.max(ans, tmp);
			}
			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        if ((i+1)%3!=0 && (i+1)%5!=0) ans += i+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
// D.

#include <iostream>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	vector<int> v[100000];
	int visited[100000] = {};
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	vector<int> q[2];
	visited[0] = 1;
	q[0].push_back(0);
	visited[n-1] = 1;
	q[1].push_back(n - 1);
	int score[2] = {};
	while (!q[0].empty() || !q[1].empty()) {
		vector<int> next[2];
		for (int i = 0; i < 2; ++i) {
			for (int x : q[i]) {
				for (int y : v[x]) {
					if (!visited[y]) {
						++score[i];
						visited[y] = 1;
						next[i].push_back(y);
					}
				}
			}
			q[i] = next[i];
		}
	}
	cout << (score[0] > score[1] ? "Fennec" : "Snuke") << endl;
	return 0;
}


Measured memory_bytes: 6460
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[] a = new long[n];
      long[] b = new long[n];
      long[] c = new long[n];
      long sum = 0;
      int cnt = 0;
      ArrayList<Integer> list =new ArrayList<>();
      for(int i = 0;i < n;i++)a[i]=sc.nextLong();
      for(int i = 0;i < n;i++){
        b[i]=sc.nextLong();
        c[i]=a[i]-b[i];
        if(c[i]>0)list.add((int)c[i]);
        else if(c[i]==0){}
        else{
          sum+= (-1)*c[i];
          cnt++;
        }
      }
      Collections.sort(list,Collections.reverseOrder());
      int sb = list.size();
      while(sum>0&&list.size()>0){
      	long h = (long)list.get(0);
        list.remove(0);
        if(h<=sum){
          sum-=h;
        }else{
          sum=0;
        }
      }
      int sa = list.size();
      if(sum>0)System.out.println(-1);
      else System.out.println(cnt+sb-sa);
    }
}


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

int main(){
    int N,W;
    cin>>N>>W;
    int v[N],w[N];
    rep(i,N)cin>>v[i]>>w[i];

    int dp[N][W+1];
    rep(i,W+1){
        if(i>=w[0])dp[0][i]=v[0];
        else dp[0][i]=0;
    }

    for(int i=1;i<N;i++){
        rep(j,W+1){
            if(j>=w[i])dp[i][j]=max(dp[i-1][j-w[i]] + v[i],dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[N-1][W]<<endl;
    return 0;
}


Measured memory_bytes: 7008
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e8 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	ll d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 3644
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
 
signed main()
{
    tezz

    int n;
    cin>>n;

    cout<<power(n, 3);
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().run();
    }

    private void run() {
        int N = sc.nextInt();
        int M = sc.nextInt();

        List<List<Integer>> roads = new ArrayList<List<Integer>>();
        for (int i = 0; i < N; i++) {
            roads.add(new ArrayList());
        }

        for (int i = 0; i < M; i++) {
            int from = sc.nextInt() - 1;
            int to = sc.nextInt() - 1;
            roads.get(from).add(to);
            roads.get(to).add(from);
        }

        for (List<Integer> list : roads) {
            System.out.println(list.size());
        }
    }
}


Measured memory_bytes: 23764
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed           as V

main :: IO ()
main = do
  (s:ss) <- getLine
  print $ min (f ss s) (1 + f ss (other s))
  where
    f [] _ = 0
    f (s:ss) p | p /= s = f ss s
               | otherwise = 1 + f ss (other p)
    other p | p == '0'  = '1'
            | otherwise = '0'


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

int main() {
int s;
int ans = 1;

cin >> s;
vector<bool> vec(2000000);
while(1){
  if(!vec.at(s)){
    vec.at(s) = true;
  }else{
    cout << ans << endl;
    return 0;
  }
  if(s%2 == 0){
    s = s/2;
    ans += 1;
  }else{
    s = 3*s + 1;
    ans += 1;
  }
}
  return 0;
}


Measured memory_bytes: 3596
module Main (main) where
import Data.Function
import Control.Monad
import System.IO
import Data.Vector.Unboxed.Mutable as MV
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  let result = count $ isPrimes 1000000
  fix $ \loop -> do
     eof <- isEOF
     unless eof $ do
        n <- readLn
        print $ result V.! (n + 1)
        loop
  return ()


count :: V.Vector Bool -> V.Vector Int
count = V.scanl' (+) 0 . V.map toInt
  where
    toInt x = if x
                 then 1
                 else 0

isPrimes :: Int -> V.Vector Bool
isPrimes size = V.create $ do
   v <- MV.replicate size True
   MV.write v 0 False
   MV.write v 1 False
   flip fix 1 $ \loop i -> do
     when (i*i < size) $ do
       prime <- MV.read v i
       when prime $ do
         sweep i v
       loop (i+1)
   return v
   where
     sweep n v = forM_ [n*2,n*3 .. MV.length v - 1] $ \i -> do
                       MV.write v i False

Measured memory_bytes: 21336
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string n,res="";
    cin >> n;
    rep(i,3) n.at(i)=='1'?res.push_back('9'):res.push_back('1');
    cout << res << endl;
}


Measured memory_bytes: 384
#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()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> b(n-1);
	rep(i,n-1) std::cin >> b[i];
	int sum = 0;
	sum+=b.front();
	sum+=b.back();
	rep(i,n-2) {
		sum+=std::min(b[i],b[i+1]);
	}
	print(sum);
	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();
        int B = sc.nextInt();

        int AB = A * B;

        if (AB % 2 ==0){
          System.out.println("No");
        }else {
              System.out.println("Yes");
        }

    }
}


Measured memory_bytes: 24148
#include<iostream>
using namespace std;
int main(void){
  int e1,e2,e3,e4;
  cin >> e1 >> e2 >> e3 >> e4;
  if(e1==e2&&e3==e4)        cout << "yes" << endl;
  else if(e1==e3&&e2==e4)   cout << "yes" << endl;
  else if(e1==e4&&e2==e3)   cout << "yes" << endl;
  else                      cout << "no"  << endl;
}


Measured memory_bytes: 3108
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
k = I()
ans = INF
for i in range(2 ** n):
    res = 1
    for j in range(n):
        if i >> j & 1:
            res *= 2
        else:
            res += k
    ans = min(ans, res)
print(ans)


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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)('A'+(s1[0]-'a')) << (char)('A'+(s2[0]-'a')) << (char)('A'+(s3[0]-'a')) << endl;
    return 0;
}


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0ll;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	if(sum%(n*(n+1)/2)){
		NO();
		return 0;
	}

	ll ope = sum/((n*(n+1))/2);
	vector<ll> d(n);
	for(int i = 0; i < n; ++i){
		d[i] = a[(i+1)%n]-a[i]-ope;
	}
	for(int i = 0; i < n; ++i){
		if(d[i] > 0 or d[i]%n != 0){
			NO();
			return 0;
		}
	}
	YES();

    return 0;
}


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

int gcd(double x, double y)
{
	int m = (int)floor(x);
	int n = (int)floor(y);
	int r;

	do {
		r = m % n;
		m = n;
		n = r;
	} while (r != 0);

	return m;
}

int main() {
  int N,X;
  scanf("%d %d", &N,&X);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }

  int dis[N];
  for (int i = 0; i < N; ++i){
    dis[i] = abs(X-a[i]);
  }

  int ans = dis[0];

  for (int i = 0; i < N; ++i){
    ans = gcd(ans,dis[i]);
  }

  cout << ans << endl;
  

}



Measured memory_bytes: 1024
n=str(input())
a=int(n[0]+n[1])
b=int(n[2]+n[3])
if 1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif 1<=a<=12:
  print('MMYY')
elif 1<=b<=12:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    string S; cin >> S;
    int K; cin >> K;
    int N = S.size();
    set<string> SS;
    set<char> SC;
    for(auto ch : S) SC.insert(ch);
    for(auto ch : SC){
        for(int i = 0; i < N; i++){
            if(S[i] == ch){
                for(int j = 1; j <= K; j++){
                    if(i+j <= N){
                        string temp = S.substr(i, j);
                        SS.insert(temp);
                    }
                }
            }
        }
        if(SS.size() >= K) break;
    }
    int cnt = 1;
    for(auto ss : SS){
        if(cnt == K) {cout << ss << endl; return 0;}
        cnt++;
    }
}

Measured memory_bytes: 256
import math
n = input()
x = map(int, raw_input().split())
y = map(int, raw_input().split())
print sum([abs(x[i]-y[i]) for i in range(len(x))])
print math.sqrt(sum([(x[i] - y[i])**2 for i in range(len(x))]))
print pow(sum([abs(x[i] - y[i])**3 for i in range(len(x))]), 1/3.0)
print max([abs(x[i]-y[i]) for i in range(len(x))])

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

int main(){
  int n;
  char s[100004];
  int cnt = 0;
  int sp = 0;

  scanf("%d", &n);
  scanf("%s", s);

  while(sp < n){
    if(s[sp] != s[sp + 1]) cnt++;

    sp++;
  }

  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 256
n = int(input())
d, x = map(int,input().split())
ans = x
def calc_eat(a):
    cnt = 0
    while True:
        if cnt*a+1 <= d:
            cnt += 1
        else:
            return cnt
for _ in range(n):
    a = int(input())
    ans += calc_eat(a)
    #print(calc_eat(a))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;

ll mpow(ll x, ll n) {
    ll res = 1;
    while (n != 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return res;
}

int main() {
    int n;
    ll ans = 1;
    cin >> n;
    map<ll, ll> mp;
    for (int i = 0; i < n; i++) {
        ll d;
        cin >> d;
        if ((i == 0 && d) || (i && d == 0)) {
            cout << 0 << endl;
            return 0;
        }
        mp[d]++;
    }
    auto ite = mp.begin();
    ite++;
    for (; ite != mp.end(); ++ite) {
        if (mp[ite->first - 1] == 0) {
            cout << 0 << endl;
            return 0;
        }
        ans = (ans * mpow(mp[ite->first - 1], ite->second)) % mod;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

  int N; cin>>N;
  vector<pair<double, double>> dot(N);
  for (auto& p : dot) {
    cin>>p.first>>p.second;
  }

  auto min_range = [&](double x, double y) {
    double r = 0;
    for (auto d : dot) {
      auto cr = sqrt(pow(d.first-x, 2) + pow(d.second-y, 2));
      r = max(cr, r);
    }
    return r;
  };

  const double phi = (sqrt(5)+1)/2;
  auto min_range_x = [&](double x) {
    double l = 0, h = 1000;
    for (int i = 0; i < 80; i++) {
      auto cl = (l*phi+h)/(phi+1);
      auto ch = (l+h*phi)/(phi+1);
      auto rl = min_range(x, cl);
      auto rh = min_range(x, ch);
      if (rl > rh) {
        l = cl;
      } else {
        h = ch;
      }
    }
    return min_range(x, (l+h)/2);
  };
  double l = 0, r = 1000;
  double ans;
  for (int i = 0; i < 80; i++) {
    auto cl = (l*phi+r)/(phi+1);
    auto cr = (l+r*phi)/(phi+1);
    auto rl = min_range_x(cl);
    auto rh = min_range_x(cr);
    if (rl > rh) {
      l = cl;
      ans = rh;
    } else {
      r = cr;
      ans = rl;
    }
  }
  cout << fixed << ans << endl;

  return 0;
}


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

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



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef std::pair<int,int> pii;
#define lson rt<<1
#define rson rt<<1|1
#define clr(a,x) memset(a,x,sizeof(a))
#define FOR(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define REP(i,a,b) for(int i=(a);i>=(int)(b);--i)
#define EFOR(i,u) for(int i=lnk[u];i;i=nxt[i])
#define DEBUG(x) std::cerr<<#x<<" = "<<x<<'\n'
const int inf=1<<30;
const long long INF=1LL<<61;
void judge() {
#ifdef SIYUAN
	freopen("in.txt","r",stdin);
#endif
}
inline char nc() {
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
template <class Tp> inline void read(register Tp &s) {
	s=0;bool neg=0;char c=nc();for(;c<'0'||c>'9';neg|=(c=='-'),c=nc());
	for(;c>='0'&&c<='9';s=10*s+(c^48),c=nc());neg&&(s=-s);
}
int pow(int x,int p,int mod) {
	int res=1;
	for(;p;p>>=1,x=1LL*x*x%mod) if(p&1) res=1LL*res*x%mod;
	return res;
}
int gcd(int x,int y) {return y?gcd(y,x%y):x;}

int main() {
//	judge();
	int x,y;
	std::cin>>x>>y;
	std::cout<<x+y/2<<std::endl;
	return 0;
}

Measured memory_bytes: 256