akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
vector<ll> v;
ll and_sum[1000 * 1000 + 10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    ll a[1010];
    cin >> N >> K;
    rep(i,0,N){
        cin >> a[i];
    }
    ll sum[1010] = {};
    rep(i,0,N){
        sum[i+1] = sum[i] + a[i];
    }
    rep(i,0,N+1){
        rep(j,0,N+1){
            if(i != j && i < j){
                v.push_back(sum[j] - sum[i]);

            }
        }
    }
    ll nn = N * (N+1) / 2;
    ll ans = 0;
    for(int t = 42; t >= 0; t--){
        ll cnt = 0;
        rep(i,0,nn){
            ll val = (1L<<t) + ans;
            if((val & v[i]) == val){
                cnt++;
            }
        }
        if(cnt >= K){
            ans += (1L<<t);
        }
    }
    print(ans);



}


Measured memory_bytes: 6512
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int M = 55556;
bool prime[55556];
bool suitable[55556];

void shieve(){
	
    for(int i=0;i<M;i++) prime[i] = true;

    prime[0] = false;
    prime[1] = false;
    for(int i=2;i<M;i++){
  	    for(int j=2*i;j<M;j+=i){
  		    prime[j] = false;
  	    }
    }
}

void shieve2(){
	for(int i=0;i<M;i++) suitable[i] = false;

	for(int i=2;i<M;i++){
		if(prime[i] && i%5==1) suitable[i] = true;
	}
}


/*int prime_count(int n){
	int res = 0;
	for(int i=0;i<=n;i++){
		if(prime[i]) res++;
	}
	return res;
}*/
int main(){
  	shieve();
  	shieve2();

  	int N;
  	cin >>  N;

  	int cnt = 0;
  	int i=2;
  	vector<int> output;
  	while(cnt<N){
  		if(suitable[i]){
  			output.push_back(i);
  			cnt++;
  		}
  		i++;
  	}

  	for(int i=0;i<N-1;i++){
  		cout << output[i] << " ";
  	}
  	cout << output[N-1] <<endl;
    
  return 0;
}













Measured memory_bytes: 384
PROGRAM ATCODER

implicit none
integer :: a,b,c
character(len=10**5) :: s


read(*,*) a,b,c

if ( a==b .and. b == c .and. c==a ) then
  print'(a)', 'Yes' 
else
  print'(a)', 'No' 
end if

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
ll n,m,ans=0;
map<ll,ll>cnt;
ll sum[maxn],num[maxn];
int main()
{
    scanf("%d%d",&n,&m);
    sum[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        sum[i]=(sum[i-1]+num[i])%m;
        ans+=cnt[sum[i]];
        cnt[sum[i]]++;
    }
    printf("%lld\n",ans+cnt[0]);
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

class Fenwick {
public:
	Fenwick(int _N) : N(_N), v(N+1, 0) {}
private:
	int N;
	vector<int> v;
public:
	void add(int val, int p){
		for(int i=p;i<=N;i+=i&-i) v[i] += val;
	}
	int sum(int p){
		int res = 0;
		for(int i=p;i>0;i-=i&-i) res += v[i];
		return res;
	}
};

int main(){
	std::ios_base::sync_with_stdio(false);
	int N, M;
	while(cin >> N >> M){
		Fenwick f(M+1);
		vector< vector<pair<int,int>> > range(M+1);
		for(int i=0;i<N;i++){
			int l, r; cin >> l >> r;
			range[r-l+1].push_back(make_pair(l, r));
		}
		cout << N << endl;
		int all = N;
		for(int i=2;i<=M;i++){
			all -= range[i-1].size();
			for(const pair<int,int>& p : range[i-1]){
				f.add(1, p.first);
				f.add(-1, p.second+1);
			}
			int res = all;
			for(int j=i;j<=M;j+=i) res += f.sum(j);
			cout << res << endl;
		}
	}
}


Measured memory_bytes: 8064
a,b,c,x = map(int, [input() for i  in range(4)])
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool> f1(N, false), f2(N, false);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a == 1) f1[b-1] = true;
        if (b == N) f2[a-1] = true;
    }
    
    bool f = false;
    for (int i = 0; i < N; i++) {
        if (f1[i] && f2[i]) {
            f = true;
            break;
        }
    }

    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
int a, b, x, res(1), d(2);
main() {
    DAU
    cin >> a >> b;
    x = __gcd(a, b);
    while (x != 1) {
        if (x % d == 0) {
            ++res;
            while (x % d == 0)
                x /= d;
        }
        if (d == 2) d = 3;
        else d += 2;
        if (d * d > x) d = x;
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 3656
/*input
happy,newyear,enjoy
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	string s,t;
	cin>>s>>t;
	if(s==t) cout<<'H';
	else cout<<'D';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	string s;
	cin >> s;
	int tmp=0;
	char ox[100010];
	int aida[100010]={};
	rep(i, s.size())
	{
		if(s[i]!='x')
		{
			ox[tmp]=s[i];
			tmp++;
		}
		else aida[tmp]++;
	}
	int muri=0;
	rep(i, tmp)
	{
		if(ox[i]!=ox[tmp-1-i]) muri=1;
	}
	if(muri==1)
	{
		cout << "-1" << endl;
	}
	else
	{
		int ans=0;
		rep(i, tmp+1) ans+=abs(aida[i]-aida[tmp-i]);
		cout << ans/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val rPoint = sc.nextInt()
    val sPoint = sc.nextInt()
    val pPoint = sc.nextInt()
    val stringT = sc.next().toCharArray.map {
      case 'r' => 0
      case 's' => 1
      case 'p' => 2
    }

    val last = Array.fill(k)(-1)

    val result = Array.fill(3)(0)

    stringT.zipWithIndex.foreach { current =>
      val lastIndex = current._2 % k
      if (last(lastIndex) == current._1) {
        last(lastIndex) = -1
      } else {
        last(lastIndex) = current._1
        result(current._1) += 1
      }
    }

    val resultValue = result(0) * pPoint + result(1) * rPoint + result(2) * sPoint

    println(resultValue.toString)
  }
}


Measured memory_bytes: 33564
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int n;
int ans;
double x,y,d;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

int main() {
	n=read();
	scanf("%lf",&d);
	d*=d;
	while (n--) {
		scanf("%lf%lf",&x,&y);
		ans+=(x*x+y*y<=d);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  double sum=0;
  cin >> n >> m;
  vector<int> v(n);
  
  for(int i=0; i<n; i++){
    cin >> v.at(i);
    sum += v.at(i);
  }
  sum = sum / (4 * m);
  int c=0;
  for(int i=0; i<n; i++){
    if(sum<=v.at(i)) c++;
  }
  
  

  if(c>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ParseException {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();  //1回の値段
		int B = sc.nextInt();  //B円持ってる
		int C = sc.nextInt();  //C回聞くと満足

		int a = B / A;
		if(a < C) {
			System.out.println(a);
		}else {
			System.out.println(C);
		}
	}
}

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

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int sum=0;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    sum+=tmp-1;
  }
  cout<<sum<<endl;
  return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll 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<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    ll A, B, N;
    cin >> A >> B >> N;
    ll max;
    ll lim;
    if(B > N) lim = N;
    else lim = B - 1;
    ll tmp1, tmp2, tmp;
    tmp1 = ((A * lim) / B);
    tmp2 = (A * (lim / B));
    max = tmp1 - tmp2;
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3632
/*
	* ernestvw
	* C++
	* May 2020
*/

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

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const long long OO = 1e18; // LLONG_MAX
const double eps = 1e-9;
const int p197 = 1000000007;
const int p998 = 998244353;
const int p103 = 1000003;

#define TEST_CASES 0

void solve(int test_case);

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

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

// ---------------------------------------------------

int a, b, n;

void solve(int test_case) {
	cin >> a >> b >> n;
	int maxi = 0;
	if(n < b) {
		cout << (a * n) / b << endl;
	}
	else {
		cout << (a * (b - 1LL)) / b << endl;
	}
}



















































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

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    if (n >= 30){
        ctn("Yes");
    }
    else{
        ctn("No")
    }
    return 0;
}

Measured memory_bytes: 3648
INF = 1000000
NMAX=40
ABMAX=10
n,ma,mb = map(int,input().split())
a=[]
b=[]
c=[]
for i in range(n):
    ai,bi,ci=map(int,input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)

dp = [[[INF]*(NMAX*ABMAX+1) for i in range(NMAX*ABMAX+1)] for i in range(n+1)]
dp[0][0][0]=0
for i in range(n):
    for j in range(NMAX*ABMAX+1):
        for k in range(NMAX*ABMAX+1):
            if dp[i][j][k] == INF:
                continue
            dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])
            dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i])

ans = INF
for j in range(1,NMAX*ABMAX+1):
    for k in range(1,NMAX*ABMAX+1):
        if (j*mb==k*ma):
            ans = min(ans,dp[n][j][k])

if ans == INF:
    ans = -1

print(ans)
            
    
    


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

void zero (int x1,int x2,int x3,int x4,int x5)
{
if(x1==0)
  cout<<"1";
  if(x2==0)
  cout<<"2";
 if(x3==0)
  cout<<"3";
  if(x4==0)
  cout<<"4";
  if(x5==0)
  cout<<"5";
   
}

int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  zero(a,b,c,d,e);
  return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
   string s;cin >> s;
   ll x=s.size();
   if(s[x-1]=='3')cout <<  "bon" <<endl;
   else if(s[x-1]=='0'||s[x-1]=='1'||s[x-1]=='6'||s[x-1]=='8'){
       cout << "pon" <<endl;
   }
   else cout << "hon" <<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	long int N, M;
	long int X[100000];
	int ans = 0;

	cin >> N >> M;
	vector<long int >h;
	for (int i = 0; i < M; i++) {
		int x;
		cin >> x;
		h.push_back(x);
	}
	sort(h.begin(), h.end());
	vector<long int>k;
	for (int i = 0; i < M - 1; i++) {
		int y;
		y = abs(h[i + 1] - h[i]);
		k.push_back(y);
	}

	sort(k.begin(), k.end());
	for (int i = 0; i < M - 1 - (N - 1); i++) {
		ans += k[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2676
#include <stdio.h>


int main(){
	int n, aux;
	scanf("%i", &n);
	for(aux=n; ; ){
		if(aux%2==0){
			if(aux%n==0){
				printf("%i\n", aux);
				break;
			}
			else
				aux=aux+2;
		}
		else
			aux++;
	}
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    int total = 0;
    int cnt = 0;
    if(b != 1){
        total += a;
        cnt++;
        while(total < b){
            total += a - 1;
            cnt++;
        }
        cout << cnt;
    }
    else cout << 0;
}


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

typedef long long ll;
typedef long double ld;

const int inf = 1e9;

ll n, x;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	map<ll,ll> m;
	ll u = 0;
	for(ll a = 1; a <= n; ++a){
		ll b = n / a;
		ll c = n - (b * a);
		if(c == 0)u++;
		m[b]++;
	}
	ll res = 0;
	for(auto x : m)res += x.first * x.second;
	cout<<res-u<<endl;

	//cout<<x.first<<" "<<x.second<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  string X,Y;
  cin>>X>>Y;
  if(X<Y) cout<<"<";
  else if(X>Y) cout<<">";
  else cout<<"=";
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
ll geti(){
    ll ret=0;char ch=getchar(),k=1;
    while((ch<'0' || ch>'9') && ch!='-')ch=getchar();
    if(ch=='-')k=0,ch=getchar();
    while(ch>='0' && ch<='9')ret=ret*10+ch-'0',ch=getchar();
    return k?ret:-ret;
}
int N,n;
int a[300052];
ll f[300052],g[300052];
priority_queue<int, vector<int>, greater<int> > qf;
priority_queue<int> qg;
int main(){
    N=geti();
    n=N*3;
    int Nx2=N*2;
    for(int i=1;i<=n;i+=1) a[i]=geti();
    for(int i=1;i<=N;i+=1) f[i]=f[i-1]+a[i],qf.push(a[i]);
    for(int i=N+1;i<=Nx2;i+=1){
        qf.push(a[i]);
        int x=qf.top(); qf.pop();
        f[i]=f[i-1]+a[i]-x;
    }
    for(int i=n;i>Nx2;i-=1) g[i]=g[i+1]+a[i],qg.push(a[i]);
    for(int i=Nx2;i>=N;i-=1){
        qg.push(a[i]);
        int x=qg.top(); qg.pop();
        g[i]=g[i+1]+a[i]-x;
    }
    ll ans=-999999999999999ll;
    for(int i=N;i<=Nx2;i+=1){
        ans=max(ans,f[i]-g[i+1]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5752
#include<iostream>
using namespace std;
int main(){
	int H,W,res[2002][2002][4]={0},ans=0;
	char s;
	bool S[2002][2002]={0};
	cin>>H>>W;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		cin>>s;
		S[i][j]=(s=='.');
	}
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		if(S[i][j-1])res[i][j][0]=res[i][j-1][0]+1;
		if(S[i-1][j])res[i][j][1]=res[i-1][j][1]+1;
	}
	for(int i=H;i>=1;i--)for(int j=W;j>=1;j--){
		if(S[i][j+1])res[i][j][2]=res[i][j+1][2]+1;
		if(S[i+1][j])res[i][j][3]=res[i+1][j][3]+1;
	}
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		if(S[i][j])ans=max(ans,res[i][j][0]+res[i][j][1]+res[i][j][2]+res[i][j][3]);
	}
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 66816
#include <bits/stdc++.h>
using namespace std;
int func (int n) {
  int sum=0;
  while(n > 0) {
    sum += n%10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  int min=10000000;
  for (int i=1; i < n; i++) {
      int d = func(i) + func(n-i);
      if (d < min) min = d;
  }
  cout << min << endl;
}

Measured memory_bytes: 3620
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    char a;cin>>a;
    if(a>='a'){
        cout<<'a'<<endl;
    }
    else{
        cout<<'A'<<endl;
    }
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3636
// AOJ 1325: Ginkgo Numbers
// 2017.10.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int a[100], sz;

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int t, i, m, n, mn, k;

	for (sz = 0, m = 0; m <= 12; m++) for (n = m; n <= 12; n++) {
		mn = m*m + n*n;
		if (mn > 1 && mn <= 150) a[sz++] = mn;
	}
	qsort(a, sz, sizeof(int), cmp);

	scanf("%d", &t);
	while (t-- > 0) {
		scanf("%d%d", &m, &n);
		mn = m*m + n*n;
		k = (int)sqrt(mn);
		for (i = 0; a[i] <= k; i++) if (mn % a[i] == 0) break;
		puts(a[i] > k ? "P" : "C");
	}
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
string dec2bin(long long decimal, int size){
  long long binary = 0;
  for(int i=0; decimal>0; i++){
    binary += decimal % 2 * pow(10, i);
    decimal = decimal / 2;
  }
  string str_binary;
  str_binary = to_string(binary);
  while(str_binary.size() != size){
    str_binary = "0" + str_binary; 
  }
  return str_binary;
}

int main() {
  string S;
  cin >> S;
  long long sum = 0;
  int num_cases = pow(2, S.size()-1);
  string e = "";
  
  if(S.size() == 1){
    cout << S << endl;
    return 0;
  }
  for(int i=0; i<num_cases; i++){
    e = S.at(0);
    string str_bin = dec2bin(i, S.size()-1);
    for(int j=0; j<S.size()-1; j++){
      if(str_bin.at(j) == '0'){
        e += S.at(j+1);
      }else{
        sum += (long long) stoll(e);
        e = S.at(j+1);
      }
    }
    sum += (long long) stoll(e);
  }
  cout << sum << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
struct enemy {
    long long damage, turn;
    enemy(long long damage, long long turn) : damage(damage), turn(turn) {}
    bool operator<(const enemy& o) const { return turn * o.damage < damage * o.turn; }
};

int main() {
    int n;
    cin >> n;
    long long h, a, d, s;
    cin >> h >> a >> d >> s;
    long long ans = 0, sum = 0;
    vector<enemy> v;
    for (int i = 0; i < n; ++i) {
        long long hi, ai, di, si;
        cin >> hi >> ai >> di >> si;
        if (ai <= d) continue;
        if (di >= a) {
            cout << "-1\n";
            return 0;
        }
        if (si > s) ans += ai - d;
        sum += ai - d;
        v.push_back(enemy(ai - d, (hi + a - di - 1) / (a - di)));
    }
    sort(v.begin(), v.end());
    for (auto& i : v) {
        ans += sum * i.turn - i.damage;
        sum -= i.damage;
        if (ans >= h) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans << "\n";
    return 0;
}



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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    s[k - 1] = (s[k - 1] - 'A') + 'a';

    cout << s << endl;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef pair<double, double> pd;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    ll d = abs(A - B);
    if((V - W) * T >= d) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

typedef struct{
  int num;
  int color;/*-1 = gray 0 = non color 1 = black*/
  int mark;
  int d;
  int f;
}Vert;

Vert G[101];

int S[101];

int A[101][101];

int count = 0,s = 0;

void visit(int n,int start){
  int i,j = 0;

  if(S[s] == 0){
      if(G[1].color == 1 && G[start].color == 1) return;
  }

  if(G[start].color == 0){
    G[start].d = ++count;
    G[start].color = -1;
    s++;
    S[s] = start;
  }

  else if(G[start].color == -1){
    for(i = 1;i <= n;i++){
      if(A[start][i] == 1 && G[i].color == 0) j = 1;
    }
    if(j == 0){
      G[start].f = ++count;
      G[start].color = 1;
      s--;
    }
  }

  for(i = 1;i <= n;i++){
    if(A[start][i] == 1 && G[i].color == 0){
      visit(n,i);
    }
  }

  if(s == 0) return;

  for(i = 1;i <= n;i++){
    if(A[S[s]][i] == 1 && G[i].color == 0) j = 1;
  }
  if(j == 0){
    G[S[s]].f = ++count;
    G[S[s]].color = 1;
    s--;
  }
  visit(n,S[s]);
}

void exvert(int n){
  int i;
  for(i = 1;i <= n;i++){
    if(G[i].mark == 0){
      visit(n,i);
    }
  }
}



int main(){
  int n,m,i,j,k,p;

  S[0] = 0;

  scanf("%d",&n);

  for(i = 0;i <= n;i++){
    for(j = 0;j <= n;j++){
      A[i][j] = 0;
      G[i].color = 0;
      G[i].mark = 0;
    }
  }

  G[1].mark = -1;
  G[0].color = 1;

  for(i = 0;i < n;i++){
    scanf("%d",&m);
    scanf("%d",&p);
    for(j = 0;j < p;j++){
      scanf("%d",&k);
      A[m][k] = 1;
      G[k].mark = 1;
    }
  }

  visit(n,1);

  exvert(n);

  for(i = 1;i <= n;i++) printf("%d %d %d\n",i,G[i].d,G[i].f);

  return 0;
}



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

const int maxn = 200010;
int n, d[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    function<void(int, int)> dfs = [&](int v, int f) {
        d[v] = d[f] + 1;
        for (int u : G[v]) if (u ^ f) dfs(u, v);
    };
    dfs(1, 0);
    int v = max_element(d + 1, d + n + 1) - d;
    dfs(v, 0);
    int l = *max_element(d + 1, d + n + 1);
    printf("%s\n", l % 3 == 2 ? "Second" : "First");
    return 0;
}

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

#define int long long

signed main() {
    string s;
    cin >> s;
    if(s=="AC") {
        cout << "Yes" << endl;
        return 0;
    }
    if(s.size()==1)  {
        cout << "No" << endl;
        return 0;
    }
    for(int i=0; i<s.size()-2; ++i) {
        if(s.substr(i,2)=="AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	vector<int> R(n, 0);
	int m = 1000;
	for (int x=1; x<m; x++) {
		for (int y=1; y<m; y++) {
			for (int z=1; z<m; z++) {
				int c = x*x + y*y + z*z + x*y + y*z + z*x;
				if (c>n) continue;
				R[c-1]++;
			}
		}
	}
	for (int i=0; i<n; i++) {
		cout << R[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"

using namespace std;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, b) FOR(i,0,b)
#define INF 1e9
#define all(a) (a).begin,(a).end()

int main(){

    string s;
    int w;
    cin>>s>>w;

    int n=s.size();
    rep(i,n){
        if((i)%w==0){
            cout<<s[i];
        }
    }
    cout<<endl;
}


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

int main(){
	ll n, k; cin >> n >> k;
	ll po[n][2];
	set<ll> x, y;
	for(ll i = 0; i < n; ++i){
		ll a, b; cin >> a >> b;
		po[i][0] = a;
		po[i][1] = b;
		x.insert(a);
		y.insert(b);
	}
	ll ans = 2 * (ll)1e9 * 2 * (ll) 1e9;
	for(auto ite = x.begin(); ite != x.end(); ++ite){
		for(auto itete = next(ite); itete != x.end(); ++itete){
			for(auto itetete = y.begin(); itetete != y.end(); ++itetete){
				for(auto itetetete = next(itetete); itetetete != y.end(); ++itetetete){
					ll x1 = *ite, x2 = *itete, y1 = *itetete, y2 = *itetetete;
					ll yo = 0;
					if(x1 > x2) x1 ^= x2 ^= x1 ^= x2;
					if(y1 > y2) y1 ^= y2 ^= y1 ^= y2;
					for(ll i = 0; i < n; ++i){
						if(x1 <= po[i][0] && po[i][0] <= x2 && y1 <= po[i][1] && po[i][1] <= y2) ++yo;
					}
					if(yo == k)	ans = min<ll>(ans, (x2 - x1) * (y2 - y1));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
						

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    string s;
    while (cin >> s) {
        int zero = count(all(s), '0');
        int one = s.size() - zero;
        cout << 2 * min(zero, one) << endl;
    }
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int a, b, i, temp;
 
    while(scanf("%d %d", &a, &b) != EOF)
    {
        temp = a + b;
        for(i=0; temp>0;i++)
            temp /= 10;
        printf("%d\n", i);
    }

    return 0;
}


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

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(a > b){
    cout << 0 << endl;
    return 0;
  }
  if(n == 1){
    if(a == b){
      cout << 1 << endl;
      return 0;
    }
    else{
      cout << 0 << endl;
      return 0;
    }
  }
  else{
    cout << (b-a)*(n-2) + 1 << endl;
  }  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct day
{
	string str;
	int n;
}ans[100];
int main()
{
	for(int i=1;i<=7;i++)
	{
		ans[i].n=i;
	}
	ans[7].str="SUN";
	ans[1].str="MON";
	ans[2].str="TUE";
	ans[3].str="WED";
	ans[4].str="THU";
	ans[5].str="FRI";
	ans[6].str="SAT";
	string t;
	cin>>t;
	for(int i=1;i<=7;i++)
	{
		if(ans[i].str==t&&t!="SUN")
		{
			cout<<7-ans[i].n;
		}
		if(t=="SUN")
		{
			cout<<7;
			break;
		}
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            return consoleReader.Repeat(N).Int.Distinct().Count();
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    public class ConsoleReader
    {
        private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries);
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = ReadLineSplit();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader : IEnumerable<ConsoleReader>
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator();
            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();

            public IEnumerable<string> String => this.Select(cr => cr.String);
            public IEnumerable<int> Int => this.Select(cr => cr.Int);
            public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1);
            public IEnumerable<long> Long => this.Select(cr => cr.Long);
            public IEnumerable<double> Double => this.Select(cr => cr.Double);
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
    #endregion
}

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

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),a[]=new int[n],i;
        String s[]=bu.readLine().split(" ");
        a[0]=Integer.parseInt(s[0]);
        int xor=a[0];
        for(i=1;i<n;i++)
        {
            a[i]=Integer.parseInt(s[i]);
            xor^=a[i];
        }
        for(i=0;i<n;i++)
        sb.append((a[i]^xor)+" ");
        System.out.print(sb);
    }
}


Measured memory_bytes: 67560
def resolve():
    # (O):80（縦最大） × 80（横最大） × 80（各マスの最大の偏り）× 160（最大何回移動する必要があるか）
    H, W = map(int, input().split())
    A = [tuple(map(int, input().split())) for _ in range(H)]
    B = [tuple(map(int, input().split())) for _ in range(H)]
    Sub = [[0] * W for i in range(H)]
    for i in range(H):
        for j in range(W):
            Sub[i][j] = abs(A[i][j] - B[i][j])

    # 移動直前の偏りをkとし、移動先のマス(i, j)
    # についてd = abs(A[i][j] - B[i][j])とした際に、
    # 移動後の偏りを abs(k - d) とするか abs(k + d) とするか」を考えることと同値である。
    # dp[i][j][k] : マス (i, j) までの経路の偏りが k になることがあるか？

    # Bitset演算 (3次元TLE)
    max_k = 80 * (H + W)
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = 1 << (max_k + Sub[0][0]) | 1 << (max_k - Sub[0][0])

    for i in range(H):
        for j in range(W):
            d = Sub[i][j]
            if i:
                dp[i][j] |= dp[i - 1][j] << d | dp[i - 1][j] >> d
            if j:
                dp[i][j] |= dp[i][j - 1] << d | dp[i][j - 1] >> d

    ans = 10 ** 18
    for i in range(max_k * 2 + 1):
        if dp[H - 1][W - 1] & (1 << i):
            ans = min(ans, abs(max_k - i))
    print(ans)


if __name__ == "__main__":
    resolve()


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

const int MAX_V = 25;
const int INF = 1 << 25;

int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;

int dijkstra(int s, int g) {
  fill(d, d + V, INF);
  fill(used, used + V, false);
  d[s] = 0;

  while(true) {
    int v = -1;
    for(int u = 0; u < V; u++) {
      if(!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }

    if(v == -1) break;
    used[v] = true;

    for(int u = 0; u < V; u++) {
      d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }

  return d[g];
}

int main() {
  int m;
  cin >> V >> m;

  for(int i = 0; i < V; i++) {
    for(int j = 0; j < V; j++) {
      cost[i][j] = INF;
    }
  }

  for(int i = 0; i < m; i++) {
    int a, b, c, d;
    scanf("%d,%d,%d,%d", &a, &b, &c, &d);
    a--, b--;
    cost[a][b] = c;
    cost[b][a] = d;
  }

  int x1, x2, y1, y2;
  scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
  x1--, x2--;
  cout << y1-(dijkstra(x1, x2) + dijkstra(x2, x1) + y2) << endl;
}

Measured memory_bytes: 3140
import Data.Maybe

main = interact $ put . sol

sol = unballance 1

put = (\(s,t) -> show s ++ " " ++ show t) . fromMaybe (-1,-1)

unballance _ []   = Nothing
unballance _ [_]  = Nothing
unballance n [a,b]
  | a==b          = Just (n,n+1)
  | otherwise     = Nothing
unballance n (a:b:c:s)
  | a==b          = Just (n,n+1)
  | a==c          = Just (n,n+2)
  | otherwise     = unballance (n+1) (b:c:s)


Measured memory_bytes: 6524
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#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 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n,m;
    scanf("%ld%ld", &n, &m);

    vector<long> a(m);
    long i;
    for(i=0; i<m; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    vector<long> b(m-1);
    for(i=0; i<m-1; i++) {
        b[i]=a[i+1]-a[i];
    }
    sort(b.begin(), b.end());

    ll sum=0;
    for(i=0; i<m-n; i++) {
        sum += b[i];
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
	static int G;
	static int D;
	static int[] p;
	static int[] c;
	static boolean[] used;
	static long ans = 1000000000;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		D = sc.nextInt();
		G = sc.nextInt();
		p = new int[D];
		c = new int[D];
		for(int i = 0;i < D;i++){
			p[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		for(int i = 0;i < D;i++){
			boolean[]used = new boolean[D];
			used[i] = true;
			dfs(i,0,0,used);
		}

		System.out.println(ans);



	}
	static void dfs(int po,int sum,int count,boolean[] used){
		//		System.out.println("sum " + sum );
		//		
		//		System.out.println("used " + used[0] + " 0 " );
		//		System.out.println("used " + used[1] + " 1 " );

		if(sum >= G){
			ans = Math.min(ans, count);
			return;
		}

		for(int i = 0;i < p[po];i++){
			sum += (po+1)*100;
			if(i == p[po]-1){			//ボーナス
				sum += c[po];
			}
			count++;
			if(sum >= G){
				ans = Math.min(ans, count);
				return;
			}
		}


		for(int i = 0;i < D;i++){
			if(!used[i]){
				used[i] = true;
				dfs(i, sum, count,used);
				used[i] = false;
			}
		}



	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 22996
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let m: usize = read();
    let mut a: BinaryHeap<u64> = (0..n).map(|_| read()).collect();
    for _ in 0..m {
        let b = a.pop().unwrap();
        a.push(b / 2);
    }

    println!("{}", (&a).into_iter().fold(0, |b, &c| b + c));
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var whxy = Input.arL;
        WriteLine($"{(double)whxy[0] * whxy[1] / 2} {ToInt32(whxy[2] * 2 == whxy[0] && whxy[1] == whxy[3] * 2)}");
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static char[][] gred(int h)
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static string[] Make<T1, T2>(out T1 v1, out T2 v2)
    {
        var r = read.Split(' ');
        v1 = getValue<T1>(r[0]);
        v2 = getValue<T2>(r[1]);
        return r;
    }
    public static string[] Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        var r = Make(out v1, out v2);
        v3 = getValue<T3>(r[2]);
        return r;
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}

Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

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

    for ( int i = n-1 ; i >= 1 ; i-- ){
        if ( h[i] - h[i-1] <  0 ) h[i-1]--; 
    }
    bool judge = true;
    for ( int i = 1 ; i < n ; i++ ){
        if ( h[i] - h[i-1] < 0 ) judge = false;
    }
    if( judge ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
package main

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

func main() {
	N := nextInt()

	a := make([]uint, N)
	x := uint(0)

	for i := 0; i < N; i++ {
		a[i] = uint(nextInt())
		x = x ^ a[i]
	}
	for i := 0; i < N; i++ {
		fmt.Print(x ^ a[i])

		if i+1 == N {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 8380