akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	var sum int
	for i := 0; i < 3; i++ {
		sum += nextInt()
	}
	if sum >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 640
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
char c[1010][1010];
int H,W;
int h1,w1,h2,w2;
bool onfield(int x,int y)
{
	return x>=1&&x<=H&&y>=1&&y<=W; 
}
int used[1010][1010];
int main()
{
	memset(used,-1,sizeof(used));
	cin>>H>>W;
	cin>>h1>>w1;
	cin>>h2>>w2;
	rep3(i,1,H+1)
	{
		rep3(j,1,W+1)
		{
			cin>>c[i][j];
		}
	}
	deque<pii> q;
	q.push_back(mp(h1,w1));
	used[h1][w1]=0;
	//bool flag=false;
	while(!q.empty())
	{
		pii p=q.front();
		q.pop_front();
		int x=p.st,y=p.nd;
		rep(i,4)
		{
			int xx=x+dx[i],yy=y+dy[i];
			if(!onfield(xx,yy)||(used[xx][yy]!=-1&&used[xx][yy]<=used[x][y])||c[xx][yy]=='#') continue;
			used[xx][yy]=used[x][y];
			//if(xx==h2&&yy==w2&&used[xx][yy]) flag=true;
			/*if(!flag) */q.push_front(mp(xx,yy));
		}
		rep3(i,x-2,x+3)
		{
			if(i>H) break;
			rep3(j,y-2,y+3)
			{
				if(j>W) break;
				if(!onfield(i,j)||(used[i][j]!=-1&&used[i][j]<=used[x][y]+1)||c[i][j]=='#'||(i==x&&abs(j-y)<=1)||(j==y&&abs(i-x)<=1)) continue;
				used[i][j]=used[x][y]+1;
				/*if(!flag) */q.push_back(mp(i,j));
			}
		}
	}
	cout<<used[h2][w2];
	return 0;
}

Measured memory_bytes: 8576
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

d = []
ans = 0
x = 0
for i, v in enumerate(a):
    d.append(b[i] - v)
    if d[i] > 0:
        x += d[i]
        ans += 1

d.sort()
if sum(d) > 0:
    print(-1)
    exit()
else:
    for v in d:
        if x <= 0:
            break
        x += v
        ans += 1

print(ans)

Measured memory_bytes: 84656
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			long x = Math.abs(sc.nextLong());
			long k = sc.nextLong();
			long d = sc.nextLong();
			long num;
			long ret;
			
			long kirisute = x/d;
			long kiriage = (x+d-1)/d;
			
			if(k<=kirisute) {
				num = k;
				ret = x-(d*num);
				System.out.println(ret);
				return;
			}
			
			long sutedistance = x-kirisute*d;
			long agedistance = kiriage*d-x;
			
			if(sutedistance<=agedistance) {
				num = kirisute;
				
			}else {
				num = kiriage;
			}
			
			ret = Math.abs(x-num*d);
			
			if((k-num)%2==0) {
				System.out.println(ret);
			}else {
				System.out.println(Math.abs(ret-d));
			}
	    }
				
	}
	


Measured memory_bytes: 35656
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N = 3;
    vector<int> v(N); for(int i=0; i<N; ++i){ cin >> v[i]; }
    
    int numEven=0;
    vector<bool> isEven(N, false);
    for(int i=0; i<N; ++i){
        if(v[i] & 1){ continue; }
        ++numEven;
        isEven[i] = true;
    }

    int cnt=0;
    if(numEven==1){
        for(int i=0; i<N; ++i){ if(!isEven[i]){++v[i];} }
        ++cnt;
    }
    if(numEven==2){
        for(int i=0; i<N; ++i){ if(isEven[i]){++v[i];} }
        ++cnt;
    }

    sort(v.begin(), v.end());
    cnt += (v[2]-v[0]) / 2;
    cnt += (v[2]-v[1]) / 2;
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


double a,b;

int main(){
	cin>>a>>b;
	double s;
	s=a*b;
	//cout<<s<<endl;
	printf("%.6f\n",s/3.305785);
	return 0;
}

Measured memory_bytes: 1236
use std::io::{BufRead, Write, stdin, stdout};
use std::cmp::min;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let mut n: u64 = split.next().unwrap().parse().unwrap();
    let mut m: u64 = split.next().unwrap().parse().unwrap();
    let mut result = min(n, m / 2);
    n -= result;
    m -= result * 2;
    result += m / 4;
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("1 6\n", "2\n");
    }
    #[test]
    fn case2() {
        test("12345 678901\n", "175897\n");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    double n;
    cin>>n;
    cout<<2*3.14*n;
}   
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3792
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        int sumA = 0, sumB = 0;
        while (N--) {
            int a, b;
            cin >> a >> b;
            if (a > b) {
                sumA += (a + b);
            } else if (a < b) {
                sumB += (a + b);
            } else {
                sumA += a;
                sumB += b;
            }
        }
        cout << sumA << " " << sumB << endl;
    }

    return 0;
}



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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){

	ll n,k;cin >> n >> k;
	vector<ll> v(n+1);
	REP(i,n)cin >> v[i+1];
	REP(i,n)v[i+1] += v[i];

	vector<ll> seica;

	for(int i = 1;i < v.size();i++){
		for(int j = 0;j < i;j++){
			seica.PB(v[i] - v[j]);
		}
	}

	for(int i = 40;i >= 0;i--){
		vector<ll> tmp;
		REP(j,seica.size()){
			if(seica[j] & (1LL << i)) {
				tmp.PB(seica[j]);
			}
		}
		if(tmp.size() >= k){
			seica = tmp;
		}
	}

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

	ll ret = seica[0];
	REP(i,seica.size()){
		ret &= seica[i];
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 6388
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;




void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> b;
    if (n & 1) {
        b.push_back(0);
        for (int i = 1; 2 * i < n; ++i) {
            b.push_back(2 * i);
            b.push_back(2 * i);
        }
    }
    else {
        for (int i = 0; 2 * i < n; ++i) {
            b.push_back(2 * i + 1);
            b.push_back(2 * i + 1);
        }
    }
    ll res = 1;
    if (a == b) {
        for (int i = 0; i < n / 2; ++i) {
            res = (res * 2) % mod;
        }
    }
    else {
        res = 0;
    }
    cout << res << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

const int K_LIM = 100;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n, 0);
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }

  for ( int q = 0; q < k; q++ ) {
    if ( q > K_LIM ) { break; }
    vector <int> b(n,0);
    for( int i = 0; i < n; i++ ) {
      int l = max(0, i-a[i]);
      int r = min(n-1, i+a[i]);
      b[l]++;
      if ( r+1 < n ) { b[r+1]--; }
    }
    for( int i = 1; i < n; i++ ) { b[i] += b[i-1]; }
    for ( int i = 0; i < n; i++ ) { a[i] = b[i]; }
  }

  for ( int i = 0; i < n; i++ ) {
    cout << a[i] << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l,r;cin>>l>>r;
    if(r-l>2019){
        cout<<0<<endl;
    }else{
        ll mi=INF;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                chmin(mi,(i*j)%2019LL);
            }
        }
        cout<<mi<<endl;
    }
}


Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

graph G;
int from[100001];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	forl(i, 0, m) {
		int a, b; cin >> a >> b;
		G[a].insert(b);
		G[b].insert(a);
	}
	queue<int> bfs;
	bfs.push(1);
	int special;
	while(!bfs.empty()) {
		int cur = bfs.front(); bfs.pop();
		fore(e, G[cur]) {
			if(from[e]) continue;
			from[e] = cur;
			bfs.push(e);
		}
	}
	println("Yes");
	forl(i, 2, n+1) println(from[i]);
}


Measured memory_bytes: 30984
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    int D = A - B;

    int E = C - D;

    if(E < 0){
      E = 0;
    }
    System.out.println(E);
    
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cmath>
using namespace std;
double R=6378.1;
main()
{
	double a,b,c,d;
	while(cin>>a>>b>>c>>d,b>=0)
	{
		double x1,x2,y1,y2,z1,z2;
		double p1=a/180*M_PI,r1=b/180*M_PI,p2=c/180*M_PI,r2=d/180*M_PI;
		x1=cos(p1)*cos(r1);
		x2=cos(p2)*cos(r2);
		y1=cos(p1)*sin(r1);
		y2=cos(p2)*sin(r2);
		z1=sin(p1);
		z2=sin(p2);
		double theta=acos((2-((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)))/2);
		cout<<round(R*theta)<<endl;
	}
}



Measured memory_bytes: 3548
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long ans = a * b / gcd(a,b);
        System.out.println(ans);
        sc.close();
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}

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

#define inf 9023372036854775807

using namespace std;

vector <pair <long long, long long>> g[100005];

bool used[100005];

map <long long, long long> p;

void dfs (long long v, long long y) {
    used[v] = true;

    p[v] = y;

    for (auto to : g[v]) {
        if (!used[to.first]) {
            dfs(to.first, y + to.second);
        }
    }

}

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

    long long n, m;
    cin >> n >> m;

    long long l, r, d;
    for (long long i = 0; i < m; ++i) {
        cin >> l >> r >> d;
        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    for (long long v = 1; v <= n; ++v) {
        if (!used[v]) {
            p.clear();
            dfs(v, 0);
            for (auto i : p) {
                for (auto to : g[i.first]) {
                    if (p[i.first] + to.second != p[to.first]) {
                        cout << "No\n";
                        return 0;
                    }
                }
            }
        }
    }

    cout << "Yes" << '\n';

    return 0;
}

Measured memory_bytes: 23552
#include <iostream>

using namespace std;

int main(){
  
  int x,y;
  cin >> x >> y;
  if((x-1)*(x-3)*(x-5)*(x-7)*(x-8)*(x-10)*(x-12)==0 && (y-1)*(y-3)*(y-5)*(y-7)*(y-8)*(y-10)*(y-12)==0){printf("Yes\n");return 0;}
  else if((x-4)*(x-6)*(x-9)*(x-11)==0 && (y-4)*(y-6)*(y-9)*(y-11)==0){printf("Yes\n");return 0;}
  else if(x==2 && y==2){cout << "Yes" << endl ;return 0;}
  else{printf("No\n");return 0;} }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

char b[8][8];
int v[8][8];


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

	int H, W;
	cin >> H >> W;

	int cnt = 0;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			cin >> b[i][j];
			cnt += b[i][j] == '#';
		}
	}

	queue<P> q;
	q.push(P(0, 0));
	while(q.size()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		if(x + 1 < W && b[y][x + 1] == '#' && !v[y][x + 1]) {
			v[y][x + 1] = 1;
			q.push(P(x + 1, y));
		}
		if(y + 1 < H && b[y + 1][x] == '#' && !v[y + 1][x]) {
			v[y + 1][x] = 1;
			q.push(P(x, y + 1));
		}
	}

	if(v[H - 1][W - 1] && cnt == H + W - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
int dp[1002][1002],ans;
int main(){
  string s,t;
  cin>>t>>s;
  s='#'+s;
  t='#'+t;
  dp[0][0]=1;
  for(int i=1;i<s.size();i++)
    for(int j=i,x=0;j<t.size();j++){
      x=(dp[i-1][j-1]+x)%M;
      if(s[i]==t[j]){
	dp[i][j]=x;
         if(i==s.size()-1)ans=(ans+x)%M;
      }
    }
  cout<<ans<<endl;
}

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

using namespace std;

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

    if (a == 5 && b == 5 && c == 7)
        cout << "YES" << endl;
    else if (a == 5 && b == 7 && c == 5)
        cout << "YES" << endl;
    else if (a == 7 && b == 5 && c == 5)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "cstdio"
int a[10005],b[10005],i,n;long long s1,s2;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
	scanf("%d",&b[i]);
	for(i=1;i<=n;i++){
		if(a[i]>b[i])s1+=a[i]-b[i];
		if(a[i]<b[i])s2+=(b[i]-a[i])>>1;
	}
	if(s1<=s2)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int cnt[26] = {};
    rep(i, N) {
        cnt[S[i] - 'a']++;
    }
    ll ans = 1;
    rep(i, 26) {
        ans = (ans * (cnt[i] + 1)) % mod;
    }
    cout << (ans + mod - 1) % mod << endl;

    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
long long x,a,b,ans,c;
int main()
{
    cin>>x>>a>>b;
    ans=x-a;
    c=ans/b;
    if(ans%b==0)
    cout<<"0"<<endl;
    else cout<<x-a-b*c<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	//mahakal();fast;

	string S;
	cin >> S;
	vector<int> dp(2);
	dp[0]=0;
	dp[1] = 1;
	for (auto c : S) {
		int num = c - '0';

		int a = min(dp[0] + num, dp[1] + 10 - num);
		int b = min(dp[0] + num + 1, dp[1] + 10 - (num + 1));
		dp = { a, b };
	}
	cout << dp[0] << endl;	
	return 0;
}

Measured memory_bytes: 1412
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<(int)n;i++)
#define REP(i,n)	for(int i=0;i<=(int)n;i++)
#define srep(i,a,n)	for(int i=a;i<(int)n;i++)
#define SREP(i,a,n)	for(int i=a;i<=(int)n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-15;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	sort(all(a));
	int x = a[n - 1];
	int y = 0;
	rep(i, n) {
		if (abs(a[n-1]-2*a[y]) > abs(a[n - 1] - 2*a[i])) {
			y = i;
		}
	}
	cout << x << " " << a[y] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {
   int a,b,c ;
   scanf("%d %d %d",&a, &b ,&c);
   int x;
   if(a==c)
   x=b;
   if(b==c)
   x=a;
   if(a==b)
   x=c;
   int ans=x;
   printf("%d\n",ans);
    return 0;
}

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

using i64 = long long;

int main() {
#ifdef HOME
	freopen("agc15a.in", "r", stdin);
	freopen("agc15a.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 a, b, c, na, nb, nc;

	cin >> a >> b >> c;
	for (int i = 0; i < 1000000; ++i) {
		if ((a | b | c) & 1) {
			cout << i << endl;
			return 0; }

		na = b / 2 + c / 2;
		nb = a / 2 + c / 2;
		nc = a / 2 + b / 2; 
		tie(a, b, c) = tie(na, nb, nc); }

	cout << -1 << endl;

	return 0; }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int A, B;
  cin>>A>>B;
  string ans="Draw";
  if(A*B==13){
    if(A==1)ans="Alice";
    else ans="Bob";
  }else if(A>B)ans="Alice";
  else if(B>A) ans="Bob";
   cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int main(int argc, char* argv[])
{
    int n,k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    printf("%d\n", (n-2+(k-1))/(k-1));


    return 0;
}



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

int n;
int num[100050];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) cin >> num[i];
    int a = 0, b = 0;
    for(int i = 0; i < n; i++) a = max(num[i], a);
    for(int i = 0; i < n; i++){
        if(abs(num[i]-a/2) < abs(b-a/2)) b = num[i];
    }
    cout << a << " " << b;
}

Measured memory_bytes: 640
fn main() {
    let v = read_vec::<usize>();
    let h = v[0];
    let w = v[1];
    let mut v = vec![];
    let mut ansv: Vec<Vec<char>> = vec![];

    for _ in 0..h {
        let line = read::<String>().chars().collect::<Vec<_>>();
        if !line.iter().all(|&c| c == '.') {
            v.push(line);
            ansv.push(vec![]);
        }
    }

    let newh = v.len();
    for j in 0..w {
        let mut f = false;
        for i in 0..newh {
            if v[i][j] != '.' {
                f = true;
                break;
            }
        }
        if f {
            for i in 0..newh {
                ansv[i].push(v[i][j]);
            }
        }
    }
    for i in 0..newh {
        for vv in ansv[i].clone() {
            print!("{}", vv);
        }
        println!("");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define LL long long
#define INF 0x3f3f3f3f
 
const int MAXN = 1e5 + 5;
const LL MOD = 1e9 + 7;
 
int f[105][6][3];
int p[105][11];
 
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif
 
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 5; j++)
            for(int k = 0; k < 2; k++)
                scanf("%d", &f[i][j][k]);
    int aaa;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= 10; j++)
            scanf("%d", &p[i][j]);
    }
    int ans = -INF;
    for(int ll = 1; ll < 1024; ll++)
    {
        int sw[10];
        int kk = ll;
        int ansn = 0;
        for(int j = 0; j < 10; j++)
        {
            sw[j] = kk % 2;
            kk = kk / 2;
        }
        for(int i = 0; i < n; i++)
        {
            int sum = 0;
            int cnt = 0;
            for(int j = 0; j < 5; j++)
            {
                for(int k = 0; k < 2; k++)
                {
                    sum += f[i][j][k]*sw[cnt++];
                }
            }
            ansn += p[i][sum];
        }
        ans = max(ans, ansn);
    }
 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll ar[N];
ll root(ll i){
	while(ar[i]!=i){
		ar[i]=ar[ar[i]];
		i=ar[i];
	}
	return i;
}
void dunion(ll a,ll b){
	a=root(a); b=root(b);
	if(a==b) return;
	if(b<a) swap(a,b);
	ar[b]=a;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		ar[i]=i;
	}
	for(i=1;i<=m;i++){
		cin>>k>>l;
		dunion(k,l);
	}
	
	k=0;
	for(i=1;i<=n;i++){
		if(ar[i]==i){
			k+=1;	
		}
	}
	cout<<(k-1);
	return 0;
}

Measured memory_bytes: 4372
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int k;
cin>>k;
int ans = 0;
FOR(i,1,k+1) {
    FOR(j,1,k+1){
        FOR(s,1,k+1) ans += __gcd(__gcd(i,j),s);
     }
}
cout<<ans;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

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

using namespace std;

typedef long long ll;
int N;
ll a[100001];
ll sum_a[100001];
int ans;
int main() {
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a,a+N);

  sum_a[0] = a[0];

  for(int i = 1; i < N; i++) sum_a[i] = a[i]+ sum_a[i-1];
 
  

  for(int i = 0; i < N; i++) {
    if(i == N-1) {ans++; break;}
    if(sum_a[i] * 2 >= a[i+1]) ans++;
    else ans = 0;
    
  }

  cout << ans <<endl;
}

  


Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    int h, w, n;
    scanf("%d %d %d", &h, &w, &n);
    int mx = max(h, w);
    if (n % mx == 0) printf("%d\n", n / mx);
    else printf("%d\n", n / mx + 1);
}

Measured memory_bytes: 128
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

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

    return n;
}

int main(void) {
    size_t N;

    scanf("%zu", &N);

    size_t sum = 0;
    size_t lim = 1;

    while (true) {
        sum += lim;

        if (N <= sum) {
            break;
        }

        lim++;
    }

    for (size_t val = 1; val <= lim; val++) {
        if (val != sum - N) {
            printf("%zu\n", val);
        }
    }

    return 0;
}


Measured memory_bytes: 256
// ConsoleApplication1.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>

//064 B

using namespace std;
int main()
{
	int N, L;
	cin >> N >> L;
	string str[110];
	for (int i = 0; i < N; i++) cin >> str[i];
	sort(str, str + N);
	string ans;
	for (int i = 0; i < N; i++) {
		ans += str[i];
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());
#define pi acos(-1)
const int N = 1<<19|3;
//inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
//inline void sub(int &x, int y){x=x-y>=0?x-y:x-y+mo;}
inline int power(int a, int n, int mo) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}

struct E {
	double a,b; //a+bi
	double imag() {return b;}
	double real() {return a;}
	E(double A=0, double B=0) {a=A; b=B;}	
};
E operator + (const E &x, const E &y) {return E(x.a+y.a,x.b+y.b);}
E operator - (const E &x, const E &y) {return E(x.a-y.a,x.b-y.b);}
E operator * (const E &x, const E &y) {return E(x.a*y.a-x.b*y.b,x.a*y.b+x.b*y.a);}
E w[N],a[N];
ll c[N];
inline void fft(E *a, int n, int tp) {
	for (int i=1,j=0; i<n; i++) {
		for (int k=(n>>1); !((j^=k)&k); k>>=1);
		if (i<j) swap(a[i],a[j]);
	}
	for (int j=2; j<=n; j<<=1) {
		w[0]=1; w[1]=E(cos(2*pi/j),tp*sin(2*pi/j));
		int m=(j>>1)-1; rep(i,2,m) w[i]=w[i-1]*w[1];
		for (register int i=0; i<n; i+=j) rep(k,0,m) {
			E x=a[i+k+(j>>1)]*w[k];
			a[i+k+(j>>1)]=a[i+k]-x; a[i+k]=a[i+k]+x;
		}
	}
}
inline void mul(E *a, E *b, int l1, int l2, ll *c) {//a[0..l1] * b[0..l2]
	int n;for(n=1;n<=l1+l2;n<<=1);
	rep(i,l1+1,n-1)a[i]=0;rep(i,l2+1,n-1)b[i]=0;
	fft(a,n,1); //fft(b,n,1);
	rep(i,0,n-1) a[i]=a[i]*b[i];
	fft(a,n,-1);
	rep(i,0,n-1) c[i]=(a[i].real())/n+0.5;
}
int n,g=2,P=200003;Vi pr={2,11,9091};
int pos[266666];
bool ck(int g){
	for(int x:pr)if(power(g,(P-1)/x,P)==1)return 0;
	return 1;
}
int main() {
	while(!ck(g))g++;
	cerr<<g<<endl;
	memset(pos,-1,sizeof(pos));
	for(int i=0,x=1;i<P-1;i++,x=1ll*x*g%P){
	//	cerr<<x<<endl;
		assert(pos[x]==-1);
		pos[x]=i;
	}
	read(n);
	ll res=0;
	rep(i,1,n){int x;read(x);if(x)a[pos[x]].a++;res=(res-1ll*x*x%P);}
	mul(a,a,P,P,c);
	
	
	rep(i,0,P*2)if(c[i]){
		res=(res+1ll*c[i]*power(g,i,P));
	//	cerr<<i<<' '<<c[i]<<' '<<power(g,i,P)<<endl;
	}
//	assert(res%2==0);
	res/=2;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 25532
#include <stdio.h>
#include <string.h>
 
void revstr(char* str){
  int size=strlen(str);
  int i,j;
  char tmp;
	
	for(i = 0,j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
}
 
int main()
{
  int rev=0;
  int posi_judge;
  int do_judge;
  char main[100000];
  char pre[300000];
  char suf[300000];
  char tmp[2];
  int Q;
  int suf_cnt=0;
  int pre_cnt=0;
  
  scanf("%s",main);
  scanf("%d",&Q);
  for(int i=0;i<Q;i++)
  {
    scanf("%d",&do_judge);
    if (do_judge==1)
    {
      rev++;
    }
    else
    {
      scanf("%d %s",&posi_judge,tmp);
      if ((posi_judge==1 && rev%2==1)||(posi_judge==2 && rev%2==0))
        suf[suf_cnt++]=tmp[0];
      else
        pre[pre_cnt++]=tmp[0];
        
    }
}
  if(rev%2==0)
  {
    revstr(pre);
    printf("%s%s%s",pre,main,suf);
  }
  else
  {
    revstr(main);
    revstr(suf);
    printf("%s%s%s",suf,main,pre);
  }
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	string t = s;
	reverse(ALL(t));
	REP(i,t.size()) {
		if(t[i] == 'b') t[i] = 'd';
		else if(t[i] == 'd') t[i] = 'b';
		else if(t[i] == 'p') t[i] = 'q';
		else if(t[i] == 'q') t[i] = 'p';
	}
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 512
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    #inputfile = open("input.txt")
    N, A, B, C = map(int, sys.stdin.readline().split())
    l = [int(sys.stdin.readline()) for i in range(N)]
    INF = 10 ** 9

    def dfs(idx, a, b, c):
        if idx == N:
            # 初期値a,b,c = 0となっているため、一本目の竹についても合成された扱いになってしまっている
            # したがって、実際はかかっていない合成コスト30を引いている
            # a,b,cのうち少なくとも一本は必ず使われる設定になっているため、30を必ず引くような実装であっても問題はない
            return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else INF
        # 一本あたりの竹について、合成しない、Aに合成、Bに合成、Cに合成の全てのパターンを以下で試行している
        no_synth = dfs(idx + 1, a, b, c)
        synth_A  = dfs(idx + 1, a + l[idx], b, c) + 10
        synth_B  = dfs(idx + 1, a, b + l[idx], c) + 10
        synth_C  = dfs(idx + 1, a, b, c + l[idx]) + 10
        return min(no_synth, synth_A, synth_B, synth_C)

    print(dfs(0,0,0,0))



Measured memory_bytes: 5320
use std::io::stdin;

#[derive(Default)]
struct Scanner {
	buffer: Vec<String>
}

impl Scanner {
	fn next<T: std::str::FromStr> (&mut self) -> T {
		loop {
			if let Some(token) = self.buffer.pop() {
				return token.parse().ok().expect("Failed parse");
			}
			let mut input = String::new();
			stdin().read_line(&mut input).expect("Failed read");
			self.buffer = input.split_whitespace().rev().map(String::from).collect();
		}
	}
}

fn main() {
	let mut scan = Scanner::default();
	let n: usize = scan.next();
	let mut a: Vec<u32> = vec![0;n];
	let mut ans: u32 = 0;
	for i in 0..n {
		a[i] = scan.next();
		ans ^= a[i];
	}
	for i in 0..n {
		if i > 0 { print!(" {}", ans ^ a[i]); }
		else { print!("{}", ans ^ a[i]); }
	}
	println!("");
}


Measured memory_bytes: 15000
#include <bits/stdc++.h>
using namespace std;
long long a[310][310], d[310][310];
int main()
{
	int n;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
			d[i][j] = a[i][j];
		}
	}
	int fg = 0;
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) continue;
				if (k != i && k != j && a[i][j]  == a[i][k] + a[k][j]) {
					d[i][j] = 0;
				}
				if (a[i][j] > a[i][k] + a[k][j]){
				//	printf("%d %d %d\n", i, j, k);
					fg = 1; 
				}
			}
		}
	}
	long long ans = 0; 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			ans += d[i][j];
		}
	}
	if (fg) ans = -1;
	printf("%lld\n", ans);
}


Measured memory_bytes: 1664
# coding: utf-8
# Your code here!


#n = int(input())
#s = input()
#a = [int(i) for i in input().split()]
#m = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行


h,w = [int(i) for i in input().split()]
b = [input() for i in range(h)]

ans = [[0]*w for i in range(h)]

for i in range(h):
    res = 0
    for j in range(w):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

#print(ans)

for i in range(h):
    res = 0
    for j in range(w-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

#print(ans)

for j in range(w):
    res = 0
    for i in range(h):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

#print(ans)

for j in range(w):
    res = 0
    for i in range(h-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

#print(ans)

print(max(max(row) for row in ans) + 1)


Measured memory_bytes: 96088
N,M = map(int,input().split())
P = [0]*M
S = [0]*M
for i in range(M):
    P[i],S[i] = map(str,input().split())
    
AC = [0]*N
WA = [0]*N
ACcount = 0
WAcount = 0
for i in range(M):
    if AC[int(P[i])-1]==0:
        if S[i] == 'WA':
            WA[int(P[i])-1] += 1
        if S[i] == 'AC':
            ACcount += 1
            AC[int(P[i])-1] = 1 
for i in range(N):
    if AC[i] == 1:
        WAcount += WA[i]
print(ACcount,WAcount)

Measured memory_bytes: 93396
import java.util.Scanner;

public class Main {


	static double esp = 0.000000001;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String string = cin.next();
			String[] s = string.split(",");
			int[] a = new int[11];
			int v1 = Integer.parseInt(s[10]);
			int v2 = Integer.parseInt(s[11]);
			int[] sum = new int[11]; 
			for(int i = 0; i< 10;i++){
				a[i+1] = Integer.parseInt(s[i]);
				sum[i+1] += sum[i] + a[i+1];
			}
			double kyori = (double)v1 * (double)sum[10]/(double)(v1+v2);
			for(int i = 1; i <= 10; i++){
				if(sum[i] >= kyori){
					System.out.println(i);
					break;
				}
			}
		}
	}

}

Measured memory_bytes: 12000