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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;


    string a , b;


    cin >> a >> b;

    if(a==b)
    {
        cout << "H" << endl;
        return 0;
    }

    if(a=="H" && b=="D")
    {
        cout << b << endl;
    }
    else if(a=="D" && b=="H")
    {
        cout << a << endl;

    }





    return 0;
}



Measured memory_bytes: 256
import math
a,b,C=map(float,input().split())
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(C)))
l=a+b+c
s=(a+b+c)/2
S=s*(s-a)*(s-b)*(s-c)
S=math.sqrt(S)
h=S/a*2
print(S)
print(l)
print(h)


Measured memory_bytes: 5692
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{

    int N;
    cin >> N;

    std::cout << std::fixed;
    std::cout << std::setprecision(5);

    double x[20];
    string u[20];

    double ans = 0;

    REP(i,N){
    	cin >> x[i] >> u[i];

    	if(u[i]=="JPY"){
    		ans += x[i];
    	}else{
    		ans += x[i]*380000.0;
    	}

    }


    cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define ll unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
 
using namespace std;
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}
 
void solve() {
  int K,S;
  cin >> K >> S;
  int cnt = 0;
  REP(i, K+1) {
    REP(j, K+1) {
      if(0 <= S-i-j && S-i-j <= K) cnt++;
    }
  }
  cout << cnt << "\n";
}
 
int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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 Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  if(a==b)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		long dp[]=new long[a+1];
		for(int i=0;i<a;i++) {
			dp[i+1]=-1;
		}
		dp[0]=1;
		dp[1]=1;
		for(int i=0;i<b;i++) {
			int c=scan.nextInt();
			dp[c]=0;
		}
		for(int i=2;i<=a;i++) {
			if(dp[i]==-1) {
				dp[i]=dp[i-1]+dp[i-2];
			}
			dp[i]%=1000000007;
		}
		System.out.println(dp[a]);
	}
}


Measured memory_bytes: 47612
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e5 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
string res;
ll n,cur,cnt = 1;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    while(n > 0){

        char c;
        if (n%26 == 0) c = 'z';
        else c = 'a' + n%26 - 1;
        res = c + res;
        if (c == 'z') n = n/26 - 1;
        else n /= 26;
    }
    cout<<res;
}



Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp64 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int A = st[0];
            int B = st[1];
            int C = st[2];

            int K = int.Parse(Console.ReadLine());

            int maxValue = Math.Max(A, Math.Max(B, C));

            Console.WriteLine(A + B + C - maxValue + maxValue * Math.Pow(2, K));

        }
    }
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define pw(x) (1ll<<(x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
typedef vector<int> vi;

const int N = 2020;

int n, m;
int f[N], h[N], dep[N];
vi g[N];

void dfs(int u, int fa, int k, int f[]) {
	f[u] = 1;
	for(auto v : g[u]) if(v != fa) {
		int &t = dep[v] = dep[u] + 1;
		if(t <= k) {
			dfs(v, u, k, f);
			f[u] += f[v];
		}
	}
}

int solve(int rt) {
	fill_n(f + 1, n, 0);
	fill_n(h + 1, n, 0);
	dep[rt] = 0;
	dfs(rt, 0, m / 2, f);
	dfs(rt, 0, m - m / 2, h);
	int ans = 0;
	for(auto u : g[rt]) ans += f[u];
	int res = ans;
	for(auto u : g[rt]) res = max(res, ans - f[u] + h[u]);
	res++;
	return res;
}

int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	cin >> n >> m;
	rep(i, 1, n) {
		int u, v; cin >> u >> v;
		g[u].pb(v), g[v].pb(u);
	}
	int ans = 0;
	rep(i, 1, n + 1) ans = max(ans, solve(i));
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 512
para_line = list(map(int,input().split(' ')))
if(para_line[1]):
    input_line = list(map(int,input().split(' ')))

ans = para_line[0]
if(para_line[1]):
    for i in range(100):
        if(para_line[0]-i not in input_line):
            ans = para_line[0]-i
            break
        if(para_line[0]+i not in input_line):
            ans = para_line[0]+i
            break
print(ans)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  if(A == B)
    cout << "Draw" << endl;
  else if(A == 1)
    cout << "Alice" << endl;
  else if(B == 1)
    cout << "Bob" << endl;
  else if(A > B)
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  if(b!=100){
  int c=pow(100,a);
  out(c*b);
  }
  else{
  int d=pow(100,a);
    out(d*101);
  }
    
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    string s, t;
    cin >> s >> t;
    vector <int> ans;
    for(int i=0; i<s.length()-t.length()+1; i++){
        bool flag=true;
        for(int j=i; j<i+t.length(); j++){
            if(s[j]==t[j-i] || s[j]=='?') continue;
            else{
                flag=false;
                break;
            }
        }
        if(flag) ans.push_back(i);
    }
    if(ans.size()==0) cout << "UNRESTORABLE" << endl;
    else{
        for(int i=ans[ans.size()-1]; i<ans[ans.size()-1]+t.length(); i++){
            s[i]=t[i-ans[ans.size()-1]];
        }
        for(int i=0; i<s.size(); i++){
            if(s[i]=='?') s[i]='a';
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    while(n)
    {
        int digit = n % 10;
        if(digit==7)
        {
            cout << "Yes";
            return 0;
        }

        n = n / 10;
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int h,w,i,j,l[27]={},v1,v2,v4,ky;
  string s[103];
  
  cin >> h >> w;
  for (i=0;i<h;i++) cin >> s[i];
  
  for (i=0;i<h;i++) for (j=0;j<w;j++){
    l[s[i][j]-'a']++;
  }
  
  v1=v2=v4=0;
  for (i=0;i<26;i++){
    if (l[i]%4==0) v4++;
    else if (l[i]%2==0) v2++;
    else v1++;
  }
  
  ky=0;
  if (h%2==1) ky+=w/2;
  if (w%2==1) ky+=h/2;
  
  if ((h%2==0 && w%2==0 && v1>0) || v1>1 || v2>ky){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for i in range(N):
  a, b = map(int, input().split())
  AB.append([a, b])

ans = 0
for ab in sorted(AB, key=lambda x: x[0]):
  if M >= ab[1]:
    ans += ab[0] * ab[1]
    M -= ab[1]
  else:
    ans += ab[0] * M
    M = 0
  if M <= 0:
    break

print(ans)

Measured memory_bytes: 21992
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int R = scanner.nextInt();

        if (N >= 10) {
            System.out.println(R);
            return;
        }

        System.out.println(R + 100 * (10 - N));
    }
}


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

void swap(int &x,int &y){
	int temp = x;
	x = y;
	y = temp;
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a > b)
		swap(a,b);
	if(b > c)
		swap(b,c);
	if(a > b)
		swap(a,b);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n=0;
	string c;
	cin>>c;
	for(i=0;i<6;++i)
	 {
	 	if(c[i]=='1')
	 	 {
	 	 	n++;  	
		 }
	 }
	cout<<n<<endl; 
	return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> c;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		c[A[i]]++;
	}
	int cnt=0;
	for (auto itr = c.begin(); itr != c.end(); itr++) {
		if (itr->second % 2 == 1) {
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 5376
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int x=fsc.nextInt();
        fsc.close();
        if(x==1) System.out.println(1);
        else{
            int max=1;
            for(int i=2;i*i<=x;i++){
                int a=i;
                while(a<=x){
                    max=Math.max(max, a);
                    a*=i;
                }
            }
            System.out.println(max);
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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; }
const int INF = 1LL << 60;

signed main() {
	i64 x;
	cin >> x;

	i64 res = 0;

	res += 1000 * (x / 500);
	x -= 500 * (x / 500);

	res += 5 * (x / 5);
	
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static final int MOD = 1000000007;
    static TreeSet<Integer> primes = new TreeSet<>();
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		for (int i = 2; i <= Math.sqrt(1000000); i++) {
		    if (isPrime(i)) {
		        primes.add(i);
		    }
		}
		int n = Integer.parseInt(br.readLine());
		String[] line = br.readLine().split(" ", n);
		ArrayList<HashMap<Integer, Integer>> maps = new ArrayList<>();
		HashMap<Integer, Integer> all = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    maps.add(getMap(Integer.parseInt(line[i])));
		    for (Map.Entry<Integer, Integer> entry : maps.get(i).entrySet()) {
		        if (!all.containsKey(entry.getKey()) || all.get(entry.getKey()) < entry.getValue()) {
		            all.put(entry.getKey(), entry.getValue());
		        }
		    }
		}
		long[] ans = new long[n];
		Arrays.fill(ans, 1L);
		for (Map.Entry<Integer, Integer> entry : all.entrySet()) {
		    for (int i = 0; i < maps.size(); i++) {
		        if (maps.get(i).containsKey(entry.getKey())) {
		            ans[i] *= pow(entry.getKey(), entry.getValue() - maps.get(i).get(entry.getKey()));
		        } else {
		            ans[i] *= pow(entry.getKey(), entry.getValue());
		        }
		        ans[i] %= MOD;
		    }
		}
		long total = 0;
		for (long x : ans) {
		    total += x;
		    total %= MOD;
		}
		System.out.println(total);
	}
	
	static boolean isPrime(int x) {
	    for (int y : primes) {
	        if (Math.sqrt(x) < y) {
	            break;
	        }
	        if (x % y == 0) {
	            return false;
	        }
	    }
	    return true;
	}
	
	static HashMap<Integer, Integer> getMap(int x) {
	    HashMap<Integer, Integer> map = new HashMap<>();
	    for (int y : primes) {
	        if (Math.sqrt(x) < y) {
	            break;
	        }
	        while (x % y == 0) {
	            if (map.containsKey(y)) {
	                map.put(y, map.get(y) + 1);
	            } else {
	                map.put(y, 1);
	            }
	            x /= y;
	        }
	    }
	    if (x > 1) {
	        if (map.containsKey(x)) {
	            map.put(x, map.get(x) + 1);
	        } else {
	            map.put(x, 1);
	        }
	    }
	    return map;
	}
	
	static long pow(long x, long p) {
	    if (p == 0) {
	        return 1;
	    } else if (p % 2 == 0) {
	        return pow(x * x % MOD, p / 2);
	    } else {
	        return pow(x, p - 1) * x % MOD;
	    }
	}
}


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


int main(){
    string str;
    int i;
    int sum;
    while ( cin >> str && str != "0") {
        sum =0;
        for (i = 0 ; i < str.size() ; i++) {
            sum += str[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, 0, n){
        cin >> l[i];
    }
    int cnt = 1;
    int di = 0;
    rep(i, 0, n){
        di = di + l[i];
        if (di > x) break;
        else cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var di = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            if (n % 2 == 1)
            {
                Console.WriteLine(0);
                return;
            }
            Array.Sort(di);
            Console.WriteLine(di[(n / 2)] - di[(n / 2) - 1]);
        }
    }
}


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

inline int read()
{
	int f=1,ret=0; char c=getchar();
	while(c<48||c>57)
	{
		if(c=='-')f=-1;
	    c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return f*ret;
}
//buanshunxu
int n,u[100005],a[100005],ans,s;

int main()
{
	n=read();
	for(int i=1; i<=n; ++i)a[i]=read();
	u[0]=0;//(-(a))
	for(int i=1; i<=n; ++i)u[i]=u[i-1]+abs(a[i]-a[i-1]);
	ans=u[n]+abs(a[n]);
	a[n+1]=0;
	for(int i=1; i<=n; ++i){
		s=ans;
		s+=abs(a[i+1]-a[i-1]);
		s-=abs(a[i]-a[i-1]);
		s-=abs(a[i]-a[i+1]);
		printf("%d\n",s);
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int a, b;
int main() {
    DAU
    cin >> a >> b;
    cout << max(a - 2 * b, 0);
    PLEC
}


Measured memory_bytes: 3692
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]

B=[0]*N
# from functools import lru_cache
# @lru_cache(maxsize=1000)
# def yapoos()
for i in A:
    if H[i[0]-1]>H[i[1]-1]:
        B[i[1]-1]=1
    elif H[i[0]-1]<H[i[1]-1]:
        B[i[0]-1]=1
    else:
        B[i[0]-1]=1
        B[i[1]-1]=1
print(B.count(0))

Measured memory_bytes: 93316
# 2019/11/16

import sys
import itertools

sys.setrecursionlimit(10**7)
n=int(input())
xy=[]
for i in range(n):
    a,b=map(int,input().split())
    xy.append((a,b))

p=list(itertools.permutations(list(range(n)),n))

avg=0
for e in p:
    for i in range(n-1):
        avg+=pow((xy[e[i]][0]-xy[e[i+1]][0])**2+(xy[e[i]][1]-xy[e[i+1]][1])**2,0.5)
print(avg/len(p))

Measured memory_bytes: 8052
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 15

def main():
    N,S = map(int,input().split())
    A = list(map(int,input().split()))

    dp = [[0]*(1 + S) for _ in range(N + 1)]
    dp[0][0] = pow(2,N,MOD)
    inv2 = pow(2,MOD - 2,MOD)
    for i,a in enumerate(A):
        for j in range(S + 1):
            if j < a:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = (dp[i][j] + dp[i][j - a] * inv2)%MOD
    print(dp[N][S])
if __name__ == '__main__':
    main()

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

class UnionFind {
private:
    const int n;
    vector<int> uni;
public:
    UnionFind(int _n) : n(_n), uni(_n, -1) {}
    int root(int x) {
        if (uni[x] < 0) return x;
        return uni[x] = root(uni[x]);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (uni[x] > uni[y]) swap(x, y);
        uni[x] += uni[y];
        uni[y] = x;
        return true;
    }
    int getSize(int x) {
        return -uni[root(x)];
    }
    void print() {
        for (auto x : uni) cout << x << " ";
        cout << endl;
    }
};

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

    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uf_blue(n);
    rep(i, k) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf_blue.unite(a, b);
    }
    UnionFind uf_red(n);
    rep(i, l) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf_red.unite(a, b);
    }

    map<Pii, int> mp;
    rep(i, n) {
        mp[Pii(uf_blue.root(i), uf_red.root(i))]++;
    }

    rep(i, n) {
        cout << (i == 0 ? "" : " ") << mp[Pii(uf_blue.root(i), uf_red.root(i))];
    }
    cout << endl;
}


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

#define endl '\n'

using namespace std;

int main(){

  int N;

  int h[101];
  
  while(1){
    cin>>N;

 
    if(N==0){
      break;
    }

    int cnt[101]={ };

    for(int i=0;i<N+1;i++){
      cin>>h[i];
    }
      
    
    for(int i=0;i<N+1;i++){
      set<int> S;
      if(i==0){
	for(int j=2;j<N+1;j++){
	  S.insert(h[j] - h[j-1]);
	}
      }else if(i==N){
	for (int j = 1; j < N; ++j) {
	  S.insert(h[j] - h[j-1]);
	}
      } else {    
	for(int j=1;j<N+1;j++){
	  if (j == i) continue;
	  if(j-1==i){
	    S.insert(h[j] - h[j-2]);
	  } else {
	    S.insert(h[j] - h[j-1]);
	  }
	}
	
      }

      if (S.size() == 1) {
	cout << h[i] << endl;
	break;
      }
    }	
	
    

  }

  
  
  return 0;

}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int S;
    cin >> S;
    int L,R;
    L = S/100;
    R = S%100;
    
    if(1<=L && L<=12){
        if(1<=R && R<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1<=R && R<=12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
import sys
n=int(input())
h=list(map(int,input().split()))
cnt=0
lst=[]
if n==1:
  print(0)
  sys.exit()
for i in range(n-1):
  if h[i+1]<=h[i]:
    cnt+=1
    if i==(n-2):
      lst.append(cnt)
  else:
    lst.append(cnt)
    cnt=0
print(max(lst))    


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

int main() {
	uint32_t N;
	cin >> N;
	
	vector<uint32_t>a(N);
	for(uint32_t i=0; i<N; i++) cin >> a[i];
	
	vector<int64_t> dp(N);
	copy(a.begin(), a.end(), dp.begin());
	
	for(uint32_t i=1; i<N; i++) {
		for(uint32_t j=0; i+j<N; j++) {
			if(i & 1) { // odd turn = Y - X;
				dp[j] = min(dp[j] - a[j+i], dp[j+1] - a[j]);
			} else { // even turn = X - Y;
				dp[j] = max(dp[j] + a[j+i], dp[j+1] + a[j]);	
			}
			//cout << dp[j] << " ";
		}
		//cout << endl;
	}
	
	if(N & 1) {
		cout << dp[0];
	} else {
		cout << -dp[0];
	}
	
	return 0;
}

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

typedef long long ll;
ll mod = 1000000007;

bool isValid(int H, int W, int x, int y){
    return x>=0 && y>=0 && x<H && y<W;
}

int main(){

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

    int H, W;
    cin >> H >> W;
    vector<vector<char>> grid(H, vector<char>(W));

    for(int i=0; i<H; i++) for(int j=0; j<W; j++) cin >> grid[i][j];

    vector<vector<ll>> dp(H, vector<ll>(W,0));

    dp[0][0]=1;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(grid[i][j]=='.'){
                if(isValid(H,W,i+1,j) && grid[i+1][j]=='.') dp[i+1][j] = (dp[i+1][j]%mod + dp[i][j]%mod )%mod;
                if(isValid(H,W,i,j+1) && grid[i][j+1]=='.') dp[i][j+1] = (dp[i][j+1]%mod + dp[i][j]%mod )%mod;
            }
        }
    }

    // for(int i=0; i<H; i++){
    //     for(int j=0; j<W; j++) cout<<dp[i][j]<<' ';
    //     cout<<'\n';
    // }

    cout<<dp[H-1][W-1]<<'\n';

    return 0;
}


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


int main(void){
  string s;cin >> s;
  string frag = "YES";
  string a[4] = {"dream","dreamer","erase","eraser"};
  int i = s.size();
  while(i>0){
    bool f = false;
    for(int j = 0;j<4;j++){
      int b = a[j].size();
      if(i-b >= 0){
        string c = s.substr(i-b,b);
        if(c == a[j]){
          i-= b;
          f = true;
          break;
        }
      }
    }
    if( f == false){
      frag = "NO";
      break;
    }
  }
  cout << frag << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int cou[5][4][11];

int main() {
    int n;
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)return 0;

        int tot = 0;
        if (m != -1)tot += m;
        if (f != -1)tot += f;

        if (m == -1 || f == -1)cout << 'F' << endl;
        else if (tot >= 80)cout << 'A' << endl;
        else if (tot >= 65)cout << 'B' << endl;
        else if (tot >= 50)cout << 'C' << endl;
        else if (tot >= 30) {
            if (r >= 50)cout << 'C' << endl;
            else cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

#define N 100001
#define P 6

int main() {
  int p[P] = {100, 101, 102, 103, 104, 105};
  int dp[P][N];
  for (int i = 0; i < P; i++) {
    dp[i][0] = 1;
  }

  for (int i = 0; i < P; i++) {
    for (int j = 1; j < N; j++) {
      int tmp = j - p[i];
      dp[i][j] = (tmp < 0 ? 0 : dp[i][tmp]) + (i - 1 < 0 ? 0 : dp[i - 1][j]);
    }
  }

  int X;
  cin >> X;
  cout << (dp[P-1][X] ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string l;
    cin >> l;
    //reverse(ALL(l));
    ll dp[2][l.length()+2];
    REP(i,2)REP(j,l.length()+2)dp[i][j]=0;
    dp[0][0]=1;
    dp[1][0]=2;
    FOR(i,1,l.length()){
        if(l[i]=='1'){
            dp[1][i]=dp[1][i-1]*2%MOD;
            dp[0][i]=dp[0][i-1]*3%MOD;
            dp[0][i]=(dp[0][i]+dp[1][i-1])%MOD;
        }else{
            dp[1][i]=dp[1][i-1];
            dp[0][i]=(dp[0][i-1]*3)%MOD;
        }
    }
    /*REP(i,2){
        REP(j,l.length()){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/


    cout << (dp[0][l.length()-1]+dp[1][l.length()-1])%MOD << endl;
    return 0;
}

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

using namespace std;
const int N = 100001;
int n,m,q, maxi[N], ans[N];
vector <vector<int> > adjList(N);

void paint(int src, int dist, int clr) {
    if(dist <= maxi[src])
        return;
    queue <pair<int,int> > q;
    q.push(make_pair(src,dist));
    while(!q.empty()) {
        int node = q.front().first, currDist = q.front().second;
        q.pop();
        if(!ans[node])
            ans[node] = clr;
        currDist--;
        if(currDist == -1)
            continue;
        for(int ch : adjList[node]) {
            if(maxi[ch] < currDist) {
                maxi[ch] = currDist;
                q.push(make_pair(ch,currDist));
            }
        }
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    memset(maxi,-1,sizeof maxi);
    for(int i = 0;i<m;i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        adjList[x].push_back(y);
        adjList[y].push_back(x);
    }
    vector <pair<int,pair<int,int> > > queries;
    scanf("%d",&m);
    for(int i = 0;i<m;i++) {
        int x,d,c;
        scanf("%d%d%d",&x,&d,&c);
        queries.push_back(make_pair(x,make_pair(d,c)));
    }
    for(int i = m-1;i>=0;i--)
        paint(queries[i].first,queries[i].second.first,queries[i].second.second);
    for(int i = 1;i<=n;i++)
        printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 9328
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a,b;
main()
{
	re(n),re(a),re(b);
	if(n==1 && a==b)return puts("1"),0;
	if(a>b || n<2)return puts("0"),0;
	n-=2;
	printf("%lld\n",n*b-n*a+1);
}


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

string s[21];
bool used[21][21];
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
    int w,h;
    while(cin>>w>>h,w){
        int sx,sy,cnt=0;
        rep(i,h){
            cin>>s[i];
            rep(j,w)if(s[i][j]=='@') sx=j,sy=i;
        }
        memset(used,0,sizeof(used));
        queue<pint> q;
        q.push({sx,sy});
        used[sy][sx]=true;
        while(!q.empty()){
            pint pi=q.front();q.pop();
            ++cnt;
            rep(i,4){
                int tx=pi.first+dx[i],ty=pi.second+dy[i];
                if(tx>=0&&ty>=0&&tx<w&&ty<h&&s[ty][tx]=='.'&&!used[ty][tx]){
                    q.push({tx,ty});
                    used[ty][tx]=true;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3168
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str =
  let len = String.length str in
  let rec f i = if i >= len then [] else str.[i] :: f (i+1) in
  f 0

let lim_width = 16006
let cp = lim_width / 2

type axis = X | Y

let swt ax = match ax with X -> Y | Y -> X

let rec parse ax acc xs =
  match xs with
  | [] -> if acc = 0 then [] else [(acc, ax)]
  | (x::xs') ->
      if x = 'T' then
        if acc = 0 then parse (swt ax) 0 xs'
        else (acc, ax) :: parse (swt ax) 0 xs'
      else parse ax (acc+1) xs'

let () =
  let s0::_ as s = read_line () |> list_of_string in
  let [xp; yp] = read_ints 2 in
  let f_first = s0 = 'F' in
  let steps = parse X 0 s in
  let xs' = steps |> List.filter (fun z -> snd z = X) |> List.map fst in
  let (x0, xs) = match xs' with
  | (z::zs) when f_first -> (z, zs)
  | _                    -> (0, xs') in
  let ys = steps |> List.filter (fun z -> snd z = Y) |> List.map fst in

  let dp = Array.make lim_width false in
  let bak = Array.make lim_width false in

  let result = List.for_all (fun (ss, src, dst) ->
    Array.fill dp 0 lim_width false; dp.(src) <- true;
    List.iter (fun s ->
      Array.fill bak 0 lim_width false;
      for_iter_ 0 lim_width (fun i ->
        if dp.(i) then (
          if i-s >= 0        then bak.(i-s) <- true;
          if i+s < lim_width then bak.(i+s) <- true));
      for_iter_ 0 lim_width (fun i ->
        dp.(i) <- bak.(i));
    ) ss;
    dp.(dst)) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in

  print_endline @@ if result then "Yes" else "No"


Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int get_total_sockets(int num_of_power_strips, int num_of_each_sockets)
{
    return num_of_power_strips*(num_of_each_sockets-1)+1;
}

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

    for(int i = 0; ; i++){
        if(B <= get_total_sockets(i, A)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
    #include<cmath>
    #include<algorithm>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int main()
    {
    	char a[8],b;
    	int x,i,k;
    	while(~scanf("%s",&a))
    	{
    		k=0;
    		b=a[0];
    		x=1;
    		for(i=1;i<=3;i++)
    		{
    			if(a[i]==b)
    				x++;
    			else
    			{
    				b=a[i];
    				x=1;
    			}
    			if(x>2)
    			{
    				printf("Yes\n");
    				k=1;
    				break;
    			}
    		}
    		if(k==0)
    			printf("No\n");
    	}
    	return 0;
    }

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

void Constraints(int x,int i) //制約関数の宣言
{
  if(1<=x&&x<=10000&&i<=10000){}
  else
  {}
}

int main(void)
{
  int x=1;
  int i=0;
  while(x!=0){
    i++;
    scanf("%d",&x);
    Constraints(x,i);
    if(x!=0){
      printf("Case %d: %d\n",i,x);
    }
  }
	return 0;
}



Measured memory_bytes: 2044
import sys
n,k = map(int,input().split())
x = list(map(int,input().split()))

mi = sys.maxsize

for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    #print(l,r)
    vall = abs(l) + abs(r - l)
    valr = abs(r) + abs(r - l)
    mi = min(mi,min(vall,valr))

print(mi)

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

void swap(int *, int *);

int main()
{
	int x,y;

	while (1)
	{

		cin >> x >> y;


		if (x == 0 && y == 0)
			break;

		if (x>y)
		swap(&x, &y);

		cout << x << " " << y << endl;

	}
	return 0;
}

void swap(int *a, int *b)
{
	int temp;
	temp = *b;
	*b = *a;
	*a = temp;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int cnt=0;
  int y=3*3*3*3*3*3*3*3*3;
  int s=9;
  while(s>=3){
    rep(i,y){
      int c=0;
      int a=1;
      int x=0,y=0,p=0;
      int w=i;
      rep(u,s){
        int z=w%3;
        w/=3;
        if(z==0){
          x++;
          c+=3*a; 
        }
        if(z==1){
          y++;
          c+=5*a;
        }
        if(z==2){
          p++;
          c+=7*a;
        }
        a*=10;
      }
      if(x*y*p!=0&&c<=n){
        cnt++;
        //if(cnt>8300)cout << c << endl;
      }
    }
    y/=3;
    s--;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//file_name:ABC86_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    int c;
    if(b<10){
        c = 10*a+b;
    }else if(b<100){
        c = 100*a+b;
    }else{
        c = 1000*a+b;
    }
    rep(i,1000){
        if(c==i*i){
            puts("Yes");
            return 0;
        }
    }

    puts("No");
    return 0;
}



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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  set<ll> s;
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
    s.insert(a.at(i));
  }
  if(a.size()==s.size())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
  


Measured memory_bytes: 11136
/*  ex5_3
    supercomputerjoi    */

#include <stdio.h>

int main(void){

    int height, width;
    char map[101][101];
    int i = 0, j = 0, k = 0;
    char isBlank;

    // input H W
    scanf("%d %d", &height, &width);

    // input a
    for(i = 0; i < height; i++){
        scanf("%s", map[i]);
    }

    // check blank row
    for(i = 0; i < height; i++){
        isBlank = 'y';
        for(j = 0; j < width; j++){
            if(map[i][j] == '#'){
                isBlank = 'n';
                break;
            }
        }
        // if row is blank
        if(isBlank == 'y'){
            // delete row and slide
            for(k = i; k < height; k++){
                for(j = 0; j < width; j++){
                    map[k][j] = map[k+1][j];
                }
            }
            i--;
            height--;
        }
    }

    // check blank col
    for(j = 0; j < width; j++){
        isBlank = 'y';
        for(i = 0; i < height; i++){
            if(map[i][j] == '#'){
                isBlank = 'n';
                break;
            }
        }
        // if col is blank
        if(isBlank == 'y'){
            // delete col and slide
            for(k = j; k < width; k++){
                for(i = 0; i < height; i++){
                    map[i][k] = map[i][k+1];
                }
            }
            j--;
            width--;
        }
    }

    // output answer
    for(i = 0; i < height; i++){
        for(j = 0; j < width; j++){
            printf("%c", map[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long LL;
// 2×3×5x7×11×13x17×19×23×29×31×37=‬‭7,420,738,134,810‬
// 1 2 3 4  5  6  7  8  9 10 11 12

LL gcd(LL a,LL b)
{
	return b?gcd(b,a%b):a;
}

int main()
{
	LL a,b;
	cin>>a>>b;
	LL n=gcd(a,b);
	int ans=1;
	for(LL i=2;i<=n/i;i++)
	{
		if(n%i==0)
		{
			ans++;
			while(n%i==0)
				n/=i;
		}
	}
	if(n!=1)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<String> moji = new ArrayList<String>();
		String mm = "10";
		while(!mm.equals("0")){
			mm = scan.nextLine();
//			String mmToSt = String.valueOf(mm);
			moji.add(mm);
//			System.out.println("scannning");
		}
//		System.out.println("finir");
		for(int i=0; i<moji.size()-1; i++){
			String henkan = moji.get(i);
			char[] ichimoji = henkan.toCharArray();
			long nagasa = henkan.length();
			long sum = 0;
			for(int ii=0; ii<nagasa; ii++){
					sum += Character.getNumericValue(ichimoji[ii]);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26376
#include<stdio.h>
int main(){
int k=0,i,ans=0,n,a[15],b[15],c[200];
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
while(1){
for(i=0;i<101;i++){
c[i]=0;
}
for(i=0;i<n;i++){
c[a[i]]++;
}
for(i=0;i<n;i++){
b[i]=c[a[i]];
}
ans++;
for(i=0;i<n;i++){
if(a[i]!=b[i]){
k=1;
break;
}
}
if(k==0){
break;
}
k=0;
for(i=0;i<n;i++){
a[i]=b[i];
}
}
printf("%d\n",ans-1);
ans=0;
printf("%d",a[0]);
for(i=1;i<n;i++){
printf(" %d",a[i]);
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2052