akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

vector<vector<int>>input(int N) {
	vector<vector<int>>v(N,vector<int>(N));
	for (int i = 0; i < N; ++i) {
		string st;cin>>st;
		for (int j = 0; j < N; ++j) {
			v[i][j]=st[j]=='.';
		}
	}
	return v;
}
vector<vector<int>>rotate(vector<vector<int>>v) {
	int N=v.size();
	vector<vector<int>>nv(v.size(),vector<int>(v.size()));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			nv[i][j]=v[j][N-1-i];
		}
	}
	return nv;
}
bool operator<(const vector<int>&l, const vector<int>&r) {
	for (int i = 0; i < l.size(); ++i) {
		if(l[i]<r[i])return true;
		else if(l[i]>r[i])return false;
	}
	return false;
}


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

pair<int, vector<int>>solve(pair<int, vector<int>>p, vector<vector<int>>field) {
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };

	const int start_id=p.first;
	const vector<int> v=p.second;

	int N=field.size();
	UnionFind uf(N*(N+1)+1);

	for (int i = 0; i < N; ++i) {
		if (v[i] == start_id) {
			uf.unionSet(i,N*(N+1));
		}
		for (int j = 0; j < N; ++j) {
			if (v[i] == v[j]) {
				uf.unionSet(i,j);
			}
		}
		if (p.second[i]&&field[i][0]) {
			uf.unionSet(i,i+N);
		}
	}
	for (int y = 0; y < N; ++y) {
		for (int x = 0; x < N; ++x) {
			for (int way = 0; way < 4; ++way) {
				int nx=x+dx[way];
				int ny=y+dy[way];
				if (nx >= 0 && nx < N&&ny >= 0 && ny < N) {
					if(field[y][x]&&field[ny][nx])uf.unionSet(x*N+N+y,nx*N+N+ny);
				}
			}
		}
	}

	vector<int>right_v(N);
	const int right_start=uf.root(N*(N+1));
	for (int i = 0; i < N; ++i) {
		right_v[i]=uf.root(N*N+i);
	}
	
	map<int,int>mp;

	vector<int>right_nv(N);
	int id=1;
	for (int i = 0; i < N; ++i) {
		if (field[i][N - 1]) {
			if (mp.find(right_v[i]) == mp.end()) {
				mp[right_v[i]]=id++;
			}
			right_nv[i]=mp[right_v[i]];
		}
		else {
			right_nv[i]=0;
		}
	}
	if (mp.find(right_start) == mp.end()) {
		return make_pair(-1,right_nv);
	}
	else {
		return make_pair(mp[right_start],right_nv);
	}
}

int main()
{
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		set<pair<int,vector<int>>>mp;
		mp.emplace(make_pair(1,vector<int>(N,1)));

		for (int i = 0; i < M; ++i) {
			set<pair<int, vector<int>>>n_mp;
			vector<vector<int>>field = input(N);
			for (auto v : mp) {
				for (int way = 0; way < 4; ++way) {
					field=rotate(field);
					auto np=solve(v,field);

					if (np.first == -1) {
						continue;
					}
					n_mp.emplace(np);
				}
			}

			mp=n_mp;
		}

		if (mp.empty()) {
			cout<<"No"<<endl;
		}
		else {
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3072
#include<cstdio>
#include<cstring> 
#include<bits/stdc++.h>
using namespace std;
int main(){
	string n;
	char ans[1005];
	int a,b,c,d,i,j;
	while(~scanf("%d",&a))
	{
		getchar();
		getline(cin,n);
		b=n.size();
		for(i=0;i<b;i++)
		{
			n[i]+=a;
			if(n[i]>90)
			n[i]-=26;
		}
	cout<<n<<endl;
		
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

type Dice struct {
	one   string
	two   string
	three string
	four  string
	five  string
	six   string
}

func (d *Dice) opN() *Dice {
	tmp := d.one // copy

	d.one = d.two
	d.two = d.six
	d.six = d.five
	d.five = tmp

	return d
}

func (d *Dice) opE() *Dice {
	tmp := d.one // copy

	d.one = d.four
	d.four = d.six
	d.six = d.three
	d.three = tmp

	return d
}

func (d *Dice) opS() *Dice {
	tmp := d.one // copy

	d.one = d.five
	d.five = d.six
	d.six = d.two
	d.two = tmp
	return d
}

func (d *Dice) opW() *Dice {
	tmp := d.one // copy

	d.one = d.three
	d.three = d.six
	d.six = d.four
	d.four = tmp
	return d
}
func main() {

	dice_s := strings.Split(nextLine(), " ")
	dice := &Dice{dice_s[0], dice_s[1], dice_s[2], dice_s[3], dice_s[4], dice_s[5]}

	operations := nextLine()
	for _, op := range operations {
		switch op {
		case 'N':
			dice = dice.opN()
		case 'E':
			dice = dice.opE()
		case 'S':
			dice = dice.opS()
		case 'W':
			dice = dice.opW()
		default:
		}
	}

	fmt.Println(dice.one)
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  long double n,m,d;
  cin >> n >> m >> d;
  long	double k=1;
  if(d==0) k=2; 
  cout << fixed << setprecision(12) << 2*(n-d)*(m-1)/n/n/k << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 401010
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;
struct hh{int t,nxt;}edge[sz<<1];
int head[sz],ecnt=1;
void make_edge(int f,int t)
{
	edge[++ecnt]=(hh){t,head[f]};
	head[f]=ecnt;
	edge[++ecnt]=(hh){f,head[t]};
	head[t]=ecnt;
}
#define v edge[i].t
int d[sz];
pii id[sz];
int ans[sz],W[sz];

int vis[sz],in[sz];
vector<int>V;
void BFS(int x)
{
	queue<int>q;q.push(x);in[x]=1;V.clear();
	while (!q.empty())
	{
		int x=q.front();q.pop();
		V.push_back(x);
		go(x) if (d[v]==d[x]&&!in[v]) in[v]=1,q.push(v);
	}
	if (V.size()==1u) exit(puts("-1")&0);
	for (auto x:V)
	{
		int flg=1;
		go(x) if (d[v]==d[x]) flg&=(ans[v]==ans[x]);
		if (flg) ans[x]^=1;
		go(x) if (d[v]==d[x]) W[i>>1]=d[x],vis[i>>1]=1;
	}
}

int main()
{
	file();
	read(n,m);
	rep(i,1,n) read(d[i]),id[i]=MP(d[i],i);
	sort(id+1,id+n+1);
	int x,y;
	rep(i,1,m) read(x,y),make_edge(x,y);
	rep(i,1,n) if (!in[id[i].sec])
	{
		BFS(id[i].sec);
		queue<int>q;
		for (auto x:V) q.push(x);
		while (!q.empty())
		{
			int x=q.front();q.pop();
			go(x) if (!vis[i>>1])
			{
				vis[i>>1]=1;
				if (d[v]<d[x]||in[v]) W[i>>1]=1e9;
				else ans[v]=ans[x]^1,in[v]=1,W[i>>1]=d[v],q.push(v);
			}
		}		
	}
	rep(i,1,n) putchar("BW"[ans[i]]); puts("");
	rep(i,1,m) printf("%d\n",W[i]);
	return 0;
}

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

int main() {
    string s;
    long long k;
    cin >> s >> k;
    for (int i = 0; i < min((long long)s.size(), k); i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(int i=0; i<2; i++) {
        if(A >= B) {
            ans += A;
            A--;
        } else {
            ans += B;
            B--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int cmd(int x,int y){
	return x>y;
}

int a[10001],b[10001];
int main(){
	
	int sum=7;
	int k;
	cin>>k;
	int f=0;
	if(k%5==0||k%2==0){
		puts("-1");
		return 0;
	}	
	int re=0,idx=0;
	do{
		re=(re*10+7)%k;
		idx++;
	}while(re!=0);
	cout<<idx;
}

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


int main(){
    double r;
    cin >>r;
    double a, b;
    a = 2* M_PI *r;
    b = r*M_PI*r;
    printf("%.6lf %.6lf",b,a);
}



Measured memory_bytes: 3292
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200100;

int n, a[N];
vector <int> u;
vector <int> v;
vector < pair <int, int> > res;

int main() {

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (a[i] >= 0) {
            u.push_back(a[i]);
        } else {
            v.push_back(-a[i]);
        }
    }

    sort(u.begin(), u.end());
    sort(v.begin(), v.end());

    if (v.size() == 0 && u[0] == 0) {
        v.push_back(0);
        u.erase(u.begin());
        sort(v.begin(), v.end());
    }

    if (u.size() == 0) {
        v[0] *= -1;
        while (v.size() >= 2) {
            res.push_back({v[0], -v.back()});
            v[0] += v.back();
            v.pop_back();
        }
        printf("%d\n", v[0]);
    } else if (v.size() == 0) {
        while (u.size() >= 3) {
            res.push_back({u[0], u.back()});
            u[0] -= u.back();
            u.pop_back();
        }
        res.push_back({u[1], u[0]});
        printf("%d\n", u[1] - u[0]);
    } else {
        for (int i = 0; i < v.size(); i++) {
            v[i] *= -1;
        }
        while (u.size() > 1) {
            res.push_back({v[0], u.back()});
            v[0] -= u.back();
            u.pop_back();
        }
        while (v.size() > 0) {
            res.push_back({u[0], v.back()});
            u[0] -= v.back();
            v.pop_back();
        }
        printf("%d\n", u[0]);
    }

    for (int i = 0; i < res.size(); i++) {
        printf("%d %d\n", res[i].first, res[i].second);
    }

    return 0;

}


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

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

int N,T,ans;
int a[200002];

int main(){
	scanf("%d %d",&N,&T);
	for(int i=1; i<=N; i++) scanf("%d",&a[i]);
	ans = T;
	for(int i=2; i<=N; i++){
		ans += min(a[i]-a[i-1],T);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 2000;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

int main() {
	int n, m;
	cin >> n >> m;
	int s[N + 1], t[N + 1];
	rep1(i, n) cin >> s[i];
	rep1(i, m) cin >> t[i];
	
	vector<vector<mint>> dp(n + 1, vector<mint>(m + 1));
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
			if(s[i] == t[j]) {
				dp[i][j] += dp[i - 1][j - 1] + 1;
			}
		}
	}

	cout << dp[n][m].x + 1 << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  long double ans = 0;

  for (ll i = 0; i < N; i++) {
    string a, b;
    cin >> a >> b;

    if (b == "JPY") {
      ans += stoll(a);
    }
    if (b == "BTC") {
      ans += stold(a) * 380000LL;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        String ans = "NG";

        for(int i = a; i <= b; i++) {
            if(i % k == 0) {
                ans = "OK";
                break;
            }
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 35728
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

bool ok(int x, int y) {
    if (x < 0 || x >= 8 || y < 0 || y >= 8) return false;
    return true;
}

bool check(int nowmap[8][8]) {
    int count = 0;
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (nowmap[i][j] == 1) {
                count++;
            }
        }
    }
    if (count >= 9) {
        return false;
    }
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (nowmap[i][j] == 1) {
                int dx[] = {1,1,-1,-1};
                int dy[] = {1,-1,-1,1};
                for (int k = 0; k < 4; k++) {
                    int px = j;
                    int py = i;
                    while(ok(px + dx[k], py + dy[k])) {
                        px += dx[k];
                        py += dy[k];
                        if (nowmap[py][px] == 1) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}

void print(int nowmap[8][8]) {
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (nowmap[i][j] == 1) {
                cout << "Q";
            } else {
                cout << ".";
            }
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    int map[8][8] = {{0}};
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        map[a][b] = 1;
    }

    std::vector<int> perm;
    for (int i = 0; i < 8; i++) {
        perm.push_back(i);
    }

    do {
        int nowmap[8][8] = {{0}};
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                nowmap[i][j] = map[i][j];
            }
        }
        for (int i = 0; i < 8; i++) {
            int x = i;
            int y = perm[i];
            
            nowmap[y][x] = 1;

        }
        if (check(nowmap)) {
            print(nowmap);
            return 0;
        }
    } while(next_permutation(perm.begin(), perm.end()));
 
    return 0;
}

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

int main(){
    ll x;
    scanf("%lld", &x);
    ll ans = x/11 * 2;
    ll t = x%11;
    if (t > 6) ans += 2;
    else if (t <= 6 && t > 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# A=[3,5,7]
n=int(input())
def dfs(s):
    if int(s)>n:
        return 0
    cnt=0
    if all(i in s for   i in "357"):
        cnt=1
    for i in "357":
        cnt+= dfs(s+i)
    return cnt 
print(dfs("0"))

Measured memory_bytes: 8976
N, K = map(int, input().split())

if K == 0:
    print(N ** 2)
    exit()

ans = 0
for mod in range(1, N + 1):
    q, r = divmod(N, mod)
    ans += max(0, mod - K) * q + max(0, r - K + 1)
print(ans)


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,X;
    cin >> A >> B >> X;
    if(A<=X){
        if(A+B>=X){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

using namespace std;

int main()
{
	vector<int> prime;
	int i,j;
	for(i=0;i<1000000;i++)
	{
		prime.push_back(1);
	}
	prime[0]=prime[1]=0;
	for(i=0;i<1000000;i++)
	{
		if(prime[i]==1)
		{
			for(j=2;j*i<1000000;j++)
			{
				prime[i*j]=0;
			}
		}
	}
	
	int a,b,n;
	
	for(;;)
	{
		cin >> a >> b >> n ;
		if(a==0 && b==0 && n==0)
			break;
		
		int count=0;
		
		for(;;a+=b)
		{
			if(prime[a]==1)
				count++;
			if(count==n)
				break;
		}
		cout << a << endl;
	}
}

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

int main(){
	const int cost[4] = {6000,4000,3000,2000};
	int t,n;
	for(int i = 0;i < 4;i++){
		cin >> t >> n;
		cout << cost[t - 1] * n << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>

using namespace std;
typedef long long int lli;
int main(){
    int n,v,l=0,p=2;
    long long int ax,min=100000000000,sumz=0;
    cin>>n;
    vector<int> a(n);
    for(;n>0;n--){
        cin>>a[l];
        if(a[l]<0){
            p++;
        }
        sumz=sumz+abs(a[l]);
        if(min>abs(a[l])){
            min=abs(a[l]);
        }

        l++;
        
        
    }
    if(p%2==1){
        ax=sumz-2*min;
    }
    else{
        ax=sumz;
    }
    cout<<ax<<endl;

return(0);
}

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

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

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(1000000)

H,W = map(int,input().split())
curX,curY = map(int,input().split())
curX -= 1
curY -= 1
goalX,goalY =  map(int,input().split())
goalX -= 1
goalY -= 1

graph = [ list(input()) for _ in range(H) ]
q = deque([(curX,curY)])
dist = [ [float('inf')]*W for _ in range(H) ]
dist[curX][curY] = 0

while q:
  r,c = q.popleft()
  if r==goalX and c==goalY: break
  hop = dist[r][c]

  # if be able to move 1 step
  for x,y in [(1,0),(-1,0),(0,1),(0,-1)]:
    nr,nc = r+x,c+y
    if 0<=nr<H and 0<=nc<W and graph[nr][nc]!="#" and dist[nr][nc]>hop:
      dist[nr][nc] = hop
      q.appendleft((nr,nc))

  for i in range(-2, 3):
    for j in range(-2, 3):
      nr,nc = r+i,c+j
      if 0<=nr<H and 0<=nc<W and graph[nr][nc]!="#" and dist[nr][nc]>hop+1:
        dist[nr][nc] = hop+1
        q.append((nr,nc))

ans = dist[goalX][goalY]
if ans == float('inf'):
  print(-1)
else:
  print(ans)


Measured memory_bytes: 137340
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;


int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto p: mp) mx = max(mx, p.second);
    for(auto p: mp) {
        if (p.second != mx) continue;
        cout << p.first << endl;
    }



}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if (N >= K)
    {
        cout << X * K + Y * (N - K) << endl;
    }
    else
    {
        cout << X * N << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//試してて御免

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() { 
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	return *cn++;
}

inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

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


	int N, X;
	N = getint();
	X = getint();

	int A = 0;
	ll kotae = 0;
	rep(i, N) {
		int B = getint();
		if (A + B > X) {
			kotae += A + B - X;
			B = X - A;
		}
		A = B;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
	int A=0,B=0,C=0,D=0;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	int a,b,t=0;
	a=A*B;
	b=C*D;
	if(a>b){t=a,a=b,b=t
	;}
	printf("%d",b);
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e5+5;

int main() {
	init();
	string str, pre, suff;
	int q, t, pos;
	bool revert = 0;
	cin >> str >> q;
	for(int i = 0; i < q; ++i){
		cin >> t;
		if(t == 1)
			revert ^= 1;
		else{
			char ch;
			cin >> pos >> ch;
			if(revert ^ (pos == 1))
				pre.push_back(ch);
			else
				suff.push_back(ch);
		}
	}
	reverse(pre.begin(), pre.end());
	str = pre + str + suff;
	if(revert)
		reverse(str.begin(), str.end());
	cout << str;
	return 0;
}


Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int mxN = 2e5 + 5;
const long oo = 1e15;

long n , x;
long a[mxN];

void Solve() {
    ft(i , 1 , n) cout << a[i] << "\n";
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n;
    ft(i , 1 , n - 1) cin >> x, a[x]++; 
}

int main() {
    FastInput();
    Input();
    Solve();
}

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

int main(void)
{
  int N,V[20],C[20],index, answer;
  scanf("%d", &N);
  answer = 0;
  for (index = 0; index < N; ++index) {
    scanf("%d", &V[index]);
  }    
  for (index = 0; index < N; ++index) {
    scanf("%d", &C[index]);
    if (C[index]<V[index]) answer += (V[index]-C[index]);
  }    

  printf("%d\n", answer);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
int main(int argc, char const* argv[])
{
	using namespace std;
	
	int a, b;
	
	// a=1;
	// b=21;
	
	cin >> a >> b;
	int rank = log10(b)+1;//桁
	
	a *= pow(10, rank );
	a += b;
	// cout << a;
	
	float f2;
	float f = sqrt(a);
  
	if( modf(f, &f2)==0.f ){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}	
	return 0;
}

Measured memory_bytes: 512
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=1e5+5;
int n;
int a[maxn],b[maxn],c[maxn];
char str[maxn];
int main(){
	rread(n);
	scanf("%s",str+1);
	rep(i,1,n)
		if(str[i]=='o')a[i]=0;
		else a[i]=1;
	for(b[1]=0;b[1]<=1;b[1]++)
		for(b[2]=0;b[2]<=1;b[2]++){
			rep(i,1,n)c[i]=a[i];
			c[1]^=b[1];
			rep(i,2,n-1){
				c[i]^=b[i];
				b[i+1]=b[i-1]^c[i];
			}
			c[n]^=b[n];
			if((b[1]==(b[n-1]^c[n]))&&(b[n]==(b[2]^c[1]))){
				rep(i,1,n)if(!b[i])putchar('S');
				else putchar('W');
				puts("");
				return 0;
			}
		}
	puts("-1");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = (1 << 21);


int main(void){
  int N,W; cin >> N >> W;
  int v[N+1],w[N+1];
  for(int i = 1; i < N+1; i++){
    cin >> v[i] >> w[i];
  }

  int T[N+1][W+1];
  rep(i,W+1){
    T[0][i] = 0;
  }
  rep(i,N+1){
    T[i][0] = 0;
  }

  for(int i = 1; i < N+1; i ++){
    for(int j = 1; j< W + 1 ; j++){
      //????????????0???????°??????????????????¨???????????????
      if(j - w[i] >= 0){
        T[i][j] = max(T[i-1][j],T[i-1][j-w[i]]+v[i]);
      }else{
        T[i][j] = T[i-1][j];
      }
    }
  }

  cout << T[N][W] << endl;

  return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>

#define MOD 1000000007
#define ll long long

using namespace std;


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

  cin >> inp;
  cout << inp[0] <<inp.size()-2<<inp[inp.size()-1]<< endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
int main(){
	int n,k;
	in2(n,k);
	printf("%d\n",!!(n%k));
	return 0; 
}

Measured memory_bytes: 128
import math
def combinations_count(n,r):
    if n<r:
        return 0
    # c=n!/(r!*(n-r)!)
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
N,M=list(map(int,input().split()))
print(combinations_count(N,2)+combinations_count(M,2))

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

namespace 三井住友信託銀行プログラミングコンテスト2019E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = ReadInt();

            long ans = 1;
            int[] c = new int[N + 1];
            c[0] = 3;

            for (int i = 0; i < N; i++)
            {
                ans *= c[A[i]] - c[A[i] + 1];

                c[A[i] + 1]++;
                ans %= 1000000007;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 20448
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,k,ans;
  cin>>n>>k;
  ans=k;
  rep(i,n-1){
    ans*=k-1;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iterator>
#include<vector>

using namespace std;

int main(void) {
    while(1) {
        int m,nmin,nmax;
        vector<int> p;
        scanf("%d%d%d",&m,&nmin,&nmax);
        if(!m) break;

        for(int i=0; i<m; i++) {
            int p_;
            scanf("%d",&p_);
            p.push_back(p_);
        }

        sort(begin(p), end(p));

        int last=p[0];
        int maxgap=-1, res=-1;
        while(1) {
            auto ub = upper_bound(begin(p), end(p), last);
            if(ub == end(p)) break;

            last = *ub;

            if(end(p) - ub > nmax || end(p) - ub < nmin) continue;

            if(maxgap < (*ub - *(ub-1))) {
                maxgap = (*ub - *(ub-1));
                res = end(p)-ub;
            }
            
        }
        printf("%d\n",res);
    }
    return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {n: i32};
    println!("{}", solve(n));
}

fn solve(n: i32) -> String {
    // write solution here
    let mut result = 0;
    for num in 1..n+1{
        result += num;
    }
    // return answer
    format!("{}", result)
}


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

int main(void){
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    string a="ABC";
    string b="ARC";
    string c;
    cin>>c;
    if(c==a){
        cout<<b<<endl;
    }else{
        cout<<a<<endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,x;
    bool b=true;
    cin>>n;
    while (n--){
        cin>>x;
        if (x%2==0){
            if (x%3==0||x%5==0){

            }
            else {
                b=false;
            }
        }
    }
    if (b)cout<<"APPROVED\n";
    else cout<<"DENIED";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Quality Checking
 */
public class Main {

	static final byte LEMON = 0;
	static final byte NORMAL = 1;
	static final byte UNKOWN = 2;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);
			int a, b, c, N;
			a = parseInt(st.nextToken());
			b = parseInt(st.nextToken());
			c = parseInt(st.nextToken());
			if ((a | b | c) == 0) {
				break;
			}
			N = parseInt(br.readLine());

			int[] parts = new int[a + b + c + 1];
			int[][] check = new int[N][4];

			Arrays.fill(parts, UNKOWN);

			for (int i = 0; i < N; i++) {
				st = new StringTokenizer(br.readLine());
				check[i][0] = parseInt(st.nextToken());
				check[i][1] = parseInt(st.nextToken());
				check[i][2] = parseInt(st.nextToken());
				check[i][3] = parseInt(st.nextToken());
				// 1st path
				if (check[i][3] == NORMAL) {
					parts[check[i][0]] = NORMAL;
					parts[check[i][1]] = NORMAL;
					parts[check[i][2]] = NORMAL;
				}
			}

			// 2nd path
			while (true) {
				int correct = 0;
				for (int i = 0; i < N; i++) {
					//
					if (check[i][3] == LEMON) {
						if (parts[check[i][0]] == NORMAL && parts[check[i][1]] == NORMAL) {
							if (parts[check[i][2]] != LEMON) {
								parts[check[i][2]] = LEMON;
								correct++;
							}
						} else if (parts[check[i][1]] == NORMAL && parts[check[i][2]] == NORMAL) {
							if (parts[check[i][0]] != LEMON) {
								parts[check[i][0]] = LEMON;
								correct++;
							}
						} else if (parts[check[i][2]] == NORMAL && parts[check[i][0]] == NORMAL) {
							if (parts[check[i][1]] != LEMON) {
								parts[check[i][1]] = LEMON;
								correct++;
							}
						}
					}
				}
				if (correct == 0) {
					break;
				}
			}

			for (int i = 1; i < parts.length; i++) System.out.println(parts[i]);
		}
	}
}

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


int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}
	vector<vector<int>> tenbo(n);
	for (int i = 0; i < m; i++) {
		int a_in, b_in;
		cin >> a_in >> b_in;
		tenbo.at(a_in - 1).push_back(b_in - 1);
		tenbo.at(b_in - 1).push_back(a_in - 1);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (tenbo.at(i).size() == 0) {
			ans++;
			continue;
		}
		bool flag = true;
		for (auto tenbo_ele : tenbo.at(i)) {
			if (h.at(i) <= h.at(tenbo_ele)) {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			ans++;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 8804
A,B,Q=map(int,input().split())
s=[]
t=[]
answer=[]
for _ in range(A):
    s.append(int(input()))
for _ in range(B):
    t.append(int(input()))
s=[-10**21]+s+[10**21]
t=[-10**21]+t+[10**21]

def binary_search(list,target):
    left=0
    right=len(list)-1
    while left<=right:
        center=(left+right)//2
        if list[center]<target and list[center+1]>target:
            return center
            break
        elif list[center]<target:
            left=center+1
        else:
            right=center-1
    
for q in range(Q):
    x=int(input())
    i=binary_search(s,x)
    j=binary_search(t,x)
    ans=min(max(x-t[j],x-s[i]),max(s[i+1]-x,t[j+1]-x),t[j+1]-s[i]+min(x-s[i],t[j+1]-x),s[i+1]-t[j]+min(x-t[j],s[i+1]-x))
    answer.append(ans)

for k in answer:
    print(k)

Measured memory_bytes: 16996
from collections import defaultdict

N, M = map(int, input().split())

prime = defaultdict(int)
m = M
for i in range(2, 10 ** 5):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

if m > 1:
    prime[10 ** 9] = 1
MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)



Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

signed main()
{
	ios_base::sync_with_stdio(false);   
    cin.tie(NULL);

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int s,w;
    	cin>>s>>w;
    	if(w>=s)
    		cout<<"unsafe"<<endl;
    	else
    		cout<<"safe"<<endl;
    	
    	
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

const int N = 101;
int n, m;
int X, Y;
char s[N][N];
short dp[N][N][N][N];
short hor[N][N];
short ver[N][N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf(" %s ", s[i]);
		for (int j = 0; j < m; j++)
			if (s[i][j] == 'E')
			{
				X = i;
				Y = j;
				s[i][j] = '.';
			}
	}
	for (int i = 0; i < n; i++)
	{
		hor[i][0] = 0;
		for (int j = 0; j < m; j++)
		{
			hor[i][j + 1] = hor[i][j];
			if (s[i][j] == 'o')
				hor[i][j + 1]++;
		}
	}
	for (int i = 0; i < m; i++)
	{
		ver[0][i] = 0;
		for (int j = 0; j < n; j++)
		{
			ver[j + 1][i] = ver[j][i];
			if (s[j][i] == 'o')
				ver[j + 1][i]++;
		}
	}
	short ans = 0;
	for (int len1 = 0; len1 < n; len1++)
		for (int len2 = 0; len2 < m; len2++)
			for (int x1 = 0; x1 + len1 < n; x1++)
				for (int y1 = 0; y1 + len2 < m; y1++)
				{
					int x2 = x1 + len1, y2 = y1 + len2;
					ans = max(ans, dp[x1][x2][y1][y2]);

					int yL = max(0, y2 - Y), yR = min(m, m - (Y - y1));
					int xL = max(0, x2 - X), xR = min(n, n - (X - x1));
					if (x1 > xL)
						dp[x1 - 1][x2][y1][y2] = max((int)dp[x1 - 1][x2][y1][y2], dp[x1][x2][y1][y2] + (hor[x1 - 1][min(yR, y2 + 1)] - hor[x1 - 1][max(yL, y1)]));
					if (x2 < xR - 1)
						dp[x1][x2 + 1][y1][y2] = max((int)dp[x1][x2 + 1][y1][y2], dp[x1][x2][y1][y2] + (hor[x2 + 1][min(yR, y2 + 1)] - hor[x2 + 1][max(yL, y1)]));
					if (y1 > yL)
						dp[x1][x2][y1 - 1][y2] = max((int)dp[x1][x2][y1 - 1][y2], dp[x1][x2][y1][y2] + (ver[min(xR, x2 + 1)][y1 - 1] - ver[max(xL, x1)][y1 - 1]));
					if (y2 < yR - 1)
						dp[x1][x2][y1][y2 + 1] = max((int)dp[x1][x2][y1][y2 + 1], dp[x1][x2][y1][y2] + (ver[min(xR, x2 + 1)][y2 + 1] - ver[max(xL, x1)][y2 + 1]));
				}
	printf("%d\n", (int)ans);

	return 0;
}

Measured memory_bytes: 101376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<bool> left(n);
    rep(i,0,n) left[i]=s[i]=='W';
    int x=0;
    int ans=n;
    rep(i,0,n) if(!left[i]) ++x;
    rep(i,0,n) {
        if(i-1>=0 && left[i-1]) ++x;
        if(!left[i]) --x;
        ans=min(ans,x);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 720
#Author: M@sud_P@rvez
from math import *
c=0
n,m=map(int,input().split())
for _ in range(n):
    a,b=map(int,input().split())
    x=a*a
    y=b*b
    z=sqrt(x+y)
    if z<=m:
        c+=1
print(c)



Measured memory_bytes: 9160
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))

suma=sum(a)
x=[0]*n
tmp=0
for i in range(1,n,2):
    tmp+=a[i]
x[0]=suma-2*tmp

for i in range(1,n):
    x[i]=2*a[i-1]-x[i-1]
for i in x:
    print(i,end=" ")

Measured memory_bytes: 19880
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split(' ').Select(s=> long.Parse(s)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var array = new List<KeyValuePair<long, long>>();

            for (var i=0;i<N;i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(s=> long.Parse(s)).ToArray();
                array.Add(new KeyValuePair<long, long>(ab[0],ab[1]));
            }

            array = array.OrderBy(s => s.Key).ToList();
            var tmpK=K;
            for(var i=0;i<N;i++)
            {
                tmpK -= array[i].Value;
                if(tmpK<1)
                {
                    Console.WriteLine(array[i].Key);
                    return;
                }
            }
        }
    }

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

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

  if ( A>=(B+1) ) {
    cout << 2*A-1 << endl;
  }

  if (B >=(A+1)) {
    cout << 2*B-1 << endl;
  }

  if (A == B) 
    cout << A+B << endl;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<ll> f(n + 1, 1);
	for (ll i = 2; i <= n; i++) {
		ll tmp = i;
		while (tmp <= n) {
			f[tmp]++;
			tmp += i;
		}
	}
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		ans += f[i] * i;
	}
	cout << ans << endl;
}


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

long long x, y;

int ans;

bool stg(long long x)
{
    for (long long i = 2; i * i <= x; ++i)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main()
{
    cin >> x >> y;
    for (long long i = 1; i * i <= x; ++i)
    {
        if (x % i == 0)
        {
            if (y % i == 0)
            {
                if (stg(i))
                    ++ans;
            }
            if ((x / i) != i && y % (x / i) == 0)
            {
                if (stg(x / i))
                    ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
N = int(input())

A_list = list(input().split())
A_list_int = [int(s) for s in A_list]

B_list = list(input().split())
B_list_int = [int(s) for s in B_list]

C_list = list(input().split())
C_list_int = [int(s) for s in C_list]

Answer = []

for i in range(0, N):
  Answer.append(B_list_int[A_list_int[i] - 1])
  if i != N and i != 0:
      if A_list_int[i - 1] == A_list_int[i] - 1:
          Answer.append(C_list_int[A_list_int[i] - 2])

print(sum(Answer))

Measured memory_bytes: 3064
n = int(input())
arr = []
for i in range(n):
  arr.append(int(input()))

minv = arr[0]
maxv = arr[1] - arr[0]
for i in range(1, len(arr)):
  maxv = max(maxv, arr[i]-minv)
  minv = min(minv, arr[i])

print (maxv)


Measured memory_bytes: 17312