akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double t, x;
    cin >> t >> x;
    double ans;
    ans = t / x;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def solve():
	n, X, *x = map(int, open(0).read().split())
	acc = [0] + list(accumulate(x))
	ans = 1 << 60
	for div in range(1, n + 1):
		cost = (div + n) * X
		mul = 3
		i = n
		while i > 0 and cost < ans:
			cost += (acc[i] - acc[max(i - div, 0)]) * max(5, mul)
			i -= div
			mul += 2
		if cost < ans:
			ans = cost
	print(ans)

if __name__ == "__main__":
	solve()

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;


#define INF INT_MAX/3

#define MAX_N 1000

//// definition of point
double EPS=1e-10;
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P
{
	double x,y;
	P(){}
	P(double x, double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	double dot(P p){
		return add(p.x*x,p.y*y);
	}
	double cross(P p){
		return add(x*p.y,-y*p.x);
	}
	double norm(){
		return x*x+y*y;
	}
	double abs(){
		return sqrt(norm());
	}
};

//// counter-clockwise
int ccw(P a, P b, P c) {
  b =b-a; c =c-a;
  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;       // a--b--c on line
  return 0;
}

//// distance of two points
double dist(P a,P b){
	return (a-b).abs();
}

int n;

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		vector<int> res;
		vector<pair<int,int> > dat[55],rdat[55];
		vector<P> ps[55];
		rep(i,n+1){
			int m;
			cin>>m;
			rep(j,m){
				double x,y;
				cin>>x>>y;
				ps[i].pb(P(x,y));
			}
			dat[i].pb(mp(dist(ps[i][0],ps[i][1]),-INF));
			rep(j,m-2){
				dat[i].pb(mp(dist(ps[i][j+1],ps[i][j+2]),ccw(ps[i][j],ps[i][j+1],ps[i][j+2])));
			}
			reverse(all(ps[i]));
			rdat[i].pb(mp(dist(ps[i][0],ps[i][1]),-INF));
			rep(j,m-2){
				rdat[i].pb(mp(dist(ps[i][j+1],ps[i][j+2]),ccw(ps[i][j],ps[i][j+1],ps[i][j+2])));
			}
		}
		repl(i,1,n+1){
			if(dat[i]==dat[0]||rdat[i]==dat[0])res.pb(i);
		}
		rep(i,res.size())cout<<res[i]<<endl;
		cout<<"+++++"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long t = sc.nextLong();
		long ans=0;
		long dif=0;
		for(int i = 0; i < n; i++){
			long a = sc.nextLong();
			if(i==0){
				dif=a;
			}else{
				if(a-dif<t){
					ans+=a-dif;
				}else{
					ans+=t;
				}
			}
			dif=a;
		}
		System.out.println(ans+t);
	}
}

Measured memory_bytes: 64536
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
double ans;
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    ans=(double)(a[0]+a[1])/2.0;
    rrep(i,2,n){
        ans=(double)(ans+a[i])/2.0;
    }
    doublecout(ans);
    return 0;
}

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

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b-1);i>=a;i--)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;

int H,W,N;
vector<string>VV;

void fall(vector<string>&F){
    rep(j,0,W){
        vi po;
        rep(i,0,H){
            if(F[i][j]!='.'){
                po.emplace_back(F[i][j]);
                F[i][j]='.';
            }
        }
        int i=H-1;
        while(po.size()){
            F[i][j]=po.back();
            po.pop_back();
            i--;
        }
    }
    // cerr<<endl;
    rep(i,0,H){
        // cerr<<F[i]<<endl;
    }
}

bool erase(vector<string>&F){
    vvi kakutei(H,vi(W));
    rep(i,0,H){
        rep(j,0,W){
            char alphabet=F[i][j];
            if(alphabet=='.')continue;
            {
                int cnt=0;
                rep(jj,j,W){
                    if(F[i][jj]!=alphabet)break;
                    cnt++;
                }
                if(cnt>=N){
                    rep(jj,j,W){
                        if(F[i][jj]!=alphabet)break;
                        kakutei[i][jj]=1;
                    }   
                }
            }
            {
                int cnt=0;
                rep(ii,i,H){
                    if(F[ii][j]!=alphabet)break;
                    cnt++;
                }
                if(cnt>=N){
                    rep(ii,i,H){
                        if(F[ii][j]!=alphabet)break;
                        kakutei[ii][j]=1;
                    }   
                }
            }
        }
    }
    // cerr<<endl;
    rep(i,0,H){
        // cerr<<F[i]<<endl;
    }
    bool flag=false;
    rep(i,0,H){
        rep(j,0,W){
            if(kakutei[i][j]){
                F[i][j]='.';
                flag=true;
            }
        }
    }
    return flag;
}
bool chain(vector<string>&F){
    fall(F);
    
    while(1){
        bool f=erase(F);
        if(f==false){
            // cerr<<"fin!"<<endl;
            break;
        }

        fall(F);
    }
    rep(i,0,H){
        rep(j,0,W){
            if(F[i][j]!='.'){
                return false;
            }
        }
    }
    return true;
}
void solve(){
    rep(i,0,H){
        rep(j,0,W-1){
            if(VV[i][j]!='.' or VV[i][j+1]!='.'){
                // cerr<<"i:"<<i<<", j:"<<j<<endl;
                vector<string>x(VV);
                swap(x[i][j],x[i][j+1]);
                bool flag=chain(x);
                if(flag){
                    cout<<"YES"<<endl;
                    return ;
                }
            }
        }
    }
    // rep(i,0,H-1){
    //     rep(j,0,W){
    //         if(VV[i][j]!='.' or VV[i+1][j]!='.'){
    //             vector<string>x(VV);
    //             swap(x[i][j],x[i+1][j]);
    //             bool flag=chain(x);
    //             if(flag){
    //                 cout<<"YES"<<endl;
    //                 return ;
    //             }
    //         }
    //     }
    // }
    cout<<"NO"<<endl;
    return;
}
signed main(void){
    cin>>H>>W>>N;
    VV.resize(H);
    rep(i,0,H){
        cin>>VV[i];
    }
    solve();

    return 0;
}


Measured memory_bytes: 3244
N, M = map(int, input().split())

F = [0 for _ in range(N)]   # from
T = [0 for _ in range(N)]   # to

for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        F[b-1] = 1
    if b == N:
        T[a-1] = 1

for i in range(1, N):
    if F[i] == T[i] == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 998244353;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    COMinit();
    ll n, m, k;
    cin >> n >> m >> k;

    ll ans = 0;
    vector<ll> factor(n + 1);

    ll fact = 1;
    rep(i, n + 1)
    {
        factor.at(i) = fact;
        fact = fact * (m - 1) % MOD;
    }

    for (int i = 0; i <= k; i++) {
        ll count = ((COM(n - 1, i) * m) % MOD) * factor.at(n - i - 1) % MOD;
        ans = (ans + count) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 16648
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,arra[1000000],arrb[1000000],arrc[1000000];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arra[i]);
	}
	int sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&arrb[i]);
		sum+=arrb[i];
	}
	for(int i=0;i<n-1;i++){
		scanf("%d",&arrc[i]);
		
	}
//	printf("%d\n",sum);
	for(int i=0;i<n-1;i++){
		if(arra[i]+1==arra[i+1]){
		//	printf("%d\n",arra[i]);
			sum+=arrc[arra[i]-1];
		}
	}
	printf("%d",sum);
	
	return 0;
}

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

int main() {
  string str;
  cin >> str;
  int n = 0;
  for(int i =0; i<str.size(); i++) {
    if(str[i]=='+')
      n+=1;
    else
      n-=1;
  }
  cout << n << endl;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main {

  def main(args: Array[String]) {
    val n = StdIn.readInt()
    val list = StdIn.readLine().split(" ").map(_.toInt)
    print(list(n - 1))
    for (i <- 0 to n - 2) {
      print(s" ${list(n - i - 2)}")
    }
    println()
  }  
}



Measured memory_bytes: 43912
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#include <unordered_map>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define all(s) s.begin(), s.end()
#define fo(i, start, finish) for(int i = start; i <= finish; i ++)
#define y1 kdfjsalsdkf

const long long MXN = 1e5 + 10;
const long long MNN = 5e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

string s;
llong ans;

int main(){
    ios;
    cin >> s;
    s += '#';
    int cnt = 0;
    for(int i = 0; i < s.size() - 1;){
        if(s[i] == 'A'){
            cnt++;
            i++;
        } else if(s[i] == 'B' && s[i + 1] == 'C'){
            ans += cnt;
            i += 2;
        } else {
            cnt = 0;
            i ++;
        }
    }
    cout << ans;
    return 0;
}


//
//
//


Measured memory_bytes: 720
object Main extends App {
  val scanner = new java.util.Scanner(System.in)
  val W = scanner.nextInt
  val H = scanner.nextInt
  val x = scanner.nextInt
  val y = scanner.nextInt
  val r = scanner.nextInt

  val result =
    if(x - r < 0) {
      false
    } else if(y + r > H) {
      false
    } else if(x + r > W) {
      false
    } else if(y - r < 0) {
      false
    } else {
      true
    }

  println(if(result) "Yes" else "No")
}

Measured memory_bytes: 44996
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer k = Integer.parseInt(scanner.next());
        Integer a = Integer.parseInt(scanner.next());
        Integer b = Integer.parseInt(scanner.next());


        int total = 0;
        for(int i = 1; i <= b; i++) {
            total = k * i;
            if(total >= a && total <= b) {
                System.out.println("OK");
                break;
            }
            if(total >= b) {
                System.out.println("NG");
                break;
            }
        }
    }
}


Measured memory_bytes: 35504
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
using namespace std;

const double pi = acos(-1);
#define nyan cout << "(=^•ω•^=)" << endl;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop while(true)

int h;
int ans;
int cnt;

signed main(){
	cin >> h;
	while(h > 0){
		h /= 2;
		ans += pow(2, cnt);
		cnt++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int main() {
    int m, f, b;
    scanf("%d %d %d", &m, &f, &b);
    if (m >= b) printf("%d\n", 0);
    else if (m < b && m+f < b) printf("NA\n");
    else printf("%d\n", b-m);
    return 0;
}



Measured memory_bytes: 2716
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(m*60)-(h*3600);
		printf("%d:%d:%d\n",h,m,s);
	return 0;
}
     

Measured memory_bytes: 592
#include <stdio.h>

int main(void){
    int a,b,d, tmp;

    scanf("%d", &a);
    scanf("%d", &b);

    if( a<b ) {
        tmp = a;
        a = b;
        b = tmp;
    }

    d = a%b;

    while(d != 0) {
        a = b;
        b = d;
        d = a%b;
    }

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

    return 0;
}


Measured memory_bytes: 2088
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long[] B = new long[N];
		Data[] d = new Data[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
			d[i] = new Data(i, A[i], B[i]);
		}
		sc.close();
		Arrays.sort(d, new MyComp());
		long k = 0;
		for(int i = 0; i < N; i++) {
			if(i % 2 == 0) {
				k += d[i].A;
			}else {
				k -= d[i].B;
			}
		}
		System.out.println(k);
	}
	static class Data{
		int id;
		long A, B,e;
		public Data(int id, long A, long B) {
			this.id = id;
			this.A = A;
			this.B = B;
			this.e = A + B;
		}
	}
	static class MyComp implements Comparator<Data>{
		@Override
		public int compare(Data d1, Data d2) {
			if(d1.e < d2.e) {
				return 1;
			}else if(d1.e == d2.e){
				return 0;
			}else {
				return -1;
			}
		}
	}
}

Measured memory_bytes: 97420
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
struct data{
	int no;
	int front;
	int size;
	int pre;
	int next;
	bool operator<(const data &right){
		return front < right.front;
	}
};

int main() {
	int n;
	while (cin>>n,n){
		vector<data> file;
		file.push_back({ -1, 0, 1000000001, -1, -1 });
		int first = 0;
		REP(i,n){
			int a, b;
			char c;
			int now = first;
			cin >> c;
			switch (c)
			{
			case 'W':
				cin >> a >> b;
				while(1){
					if (file[now].no == -1){
						if (file[now].size > b){
							file.push_back({ a, file[now].front, b, file[now].pre, now });
							file[now].front += b;
							file[now].size -= b;
							if (file[now].pre == -1)
								first = file.size() - 1;
							else
							file[file[now].pre].next = file.size() - 1;
							file[now].pre = file.size() - 1;
							break;
						} else if(file[now].size==b){
							file[now].no = a;
							break;
						}
						else{
							file[now].no = a;
							b -= file[now].size;
						}
					}
					now = file[now].next;
				}
				break;
			case 'D':
				cin >> a;
				REP(j, file.size()){
					if (file[j].no == a)
						file[j].no = -1;
				}
				break;
			case 'R':
				cin >> a;
				while(1){
					if (file[now].front <= a&&a <file[now].front+file[now].size){
						cout << file[now].no << endl;
						break;
					}
					else{
						now = file[now].next;
					}
				}
				break;
			}
			
		}
		cout << endl;
	}
}

Measured memory_bytes: 3216
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

#define MOD (ll)(1e9+7)

ll fact(ll x)          //defining the function or function definition
{
	ll i, f = 1;
	for (i = 2; i <= x; i++) {
		f *= i;
		f %= MOD;
	}
	return f;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll n = fact(N);
	ll m = fact(M);
	ll ans = n * m;
	ans %= MOD;
	if (N == M) {
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        long K = sc.nextInt();
        long current = 0;
        Set<Long> exist = new HashSet<>();
        int result = -1;
        for (int i = 1; i <= K ;i++) {
            current = (current * 10 + 7) % K;
            if (exist.contains(current)) {
                break;
            } else {
                if (current == 0) {
                    result = i;
                    break;
                } else {
                    exist.add(current);
                }
            }
        }
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 132096
n,m,x = map(int, input().split(" "))
hon = []
check = False
for i in range(n):
    hon.append(list(map(int, input().split(" "))))
mini = n * (10 ** 10)
for bit in range(2 ** n):
    nouryoku = [0 for k in range(m + 1)]
    for j in range(n):
        mask = 1 << j
        if bit&mask:
            for k in range(m + 1):
                nouryoku[k] += hon[j][k]
    temp = 1
    for i in range(1, m + 1):
        temp *= nouryoku[i] // x
    if temp >= 1:
        check = True
        if nouryoku[0] < mini:
            mini = nouryoku[0]
if check:
    print(mini)
else:
    print(-1)

Measured memory_bytes: 9180
using System;

class Practice
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,] cood = new int[n + 1, 3];
        cood[0, 0] = cood[0, 1] = cood[0, 2] = 0;
        for (int i = 1; i <= n; ++i)
        {
            string[] tmp = Console.ReadLine().Split();
            for (int j = 0; j < 3; ++j)
            {
                cood[i, j] = int.Parse(tmp[j]);
            }
        }
        for (int i = 1; i <= n; ++i)
        {
            int t = cood[i, 0] - cood[i - 1, 0];
            int manhattan = Math.Abs(cood[i, 1] - cood[i - 1, 1]) + Math.Abs(cood[i, 2] - cood[i - 1, 2]);
            if (manhattan > t || (t - manhattan) % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


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

using namespace std;

int N,a[101010];
typedef long long LL;

int main() {
	scanf("%d",&N);
	for (int i=1;i<=N;i++) {
		scanf("%d",&a[i]);
	}
	LL ans1 = 0, ans2 = 0, S1 = 0, S2 = 0;
	for (int i=1;i<=N;i++) {
		S1 += a[i];
		S2 += a[i];
		if (i % 2 == 0) {
			if (S1 <= 0) {
				ans1 += abs(S1) + 1;
				S1 = 1;
			}
			if (S2 >= 0) {
				ans2 += abs(S2) + 1;
				S2 = -1;
			}
		} else {
			if (S1 >= 0) {
				ans1 += abs(S1) + 1;
				S1 = -1;
			}
			if (S2 <= 0) {
				ans2 += abs(S2) + 1;
				S2 = 1;
			}
		}
	}
	printf("%lld\n",min(ans1,ans2));
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    ll n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(n, 0));
    for(auto& x : a)
        for(auto& y : x)
            cin >> y;

    vector<ll> v(1 << n, 0);
    for(ll i = 0; i < (1 << n); ++i){
        for(ll j = 0; j < n; ++j){
            for(ll k = j + 1; k < n; ++k){
                if((i & (1 << j)) && (i & (1 << k))){
                    v[i] += a[j][k];
                }
            }
        }
    }

    vector<ll> dp(1 << n, -1e18);
    dp[0] = 0;

    for(ll i = 0; i < (1 << n); ++i){
        ll mask = (~i) & ((1 << n) - 1);
        for(ll j = mask; j > 0; j = (j - 1) & mask){
            dp[i | j] = max(dp[i | j], dp[i] + v[j]);
        }
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
//#define ceil(x,y) ((x+y-1)/y)
//sin(x*pi/180)
//alot of memset may cause TLE
#define TC int t;cin>>t;while(t--)
//</DEFINE>
int dx[] = { 0,0,-1,1,1,1,-1,-1 };
int dy[] = { 1,-1,0,0,1,-1,1,-1 };
ll n, slime[401];
ll res[401][401];
//<FUNCTIONS>
ll solve(int l = 1, int r = n ) {
	ll& mn = res[l][r];
	if (~mn)return mn;
	if (l == r)return 0;
	mn = 1e18;
	ll x, y;
	for (int i = l + 1; i <= r; i++) {
		mn = min(mn, solve(l, i - 1) + slime[i - 1] - slime[l - 1] + solve(i, r) + slime[r] - slime[i - 1]);
	}
	return mn;
}
//</FUNCTIONS>	
int main() {
	Fast();
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> slime[i], slime[i] += slime[i - 1];
	}
	memset(res, -1, sizeof(res));
	cout << solve();
}

Measured memory_bytes: 4924
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n ;
  vector<int>a(n-1);
  vector<int>b(n);
  rep(i,n-1) cin >> a.at(i);
  rep(i,n-1) b.at(a.at(i)-1 )++;
  
  rep(i,n) cout << b.at(i) <<endl;
}


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

using namespace std;


int main() {

    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long ans = 0;
    int MAX = N + 1;
    for (int i = 0; i < MAX; ++i) {
        int r = i * R;
        if (r > N){ break;}
        for (int j = 0; j < MAX; ++j) {
            if (i * R + j * G > N ){break;}
            long long balls = i * R + j * G;
            if ((N - balls) % B == 0 && (N - balls) / B >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        String str = in.next();
        if (num < 3200 ){
            str = "red";
        }
        System.out.println(str);

        
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

int main(void)
{
	int i, j;
	int num[100];
	int n[100];
	int max;
	
	for (i = 0; i < 100; i++){
		num[i] = 0;
	}
	
	i = 0;
	
	while ( scanf("%d", &n[i]) != EOF){
		num[n[i]]++;
	}
	
	max = num[0];
	
	for (i = 1; i < 100; i++){
		if (max < num[i]){
			max = num[i];
		}
	}
	for (j = 0; j < 100; j++){
		if (max == num[j]){
			printf("%d\n", j);
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

struct elem{
    int l,r;
};

int N,M,t[300010],ans[300010]; elem arr[300010];
vector<int> d[300010];

void update(int pos){
    for (; pos<=M; pos+=(pos&-pos))
        t[pos]++;
}

int query(int pos){
    int res=0;
    for (; pos>0; pos-=(pos&-pos))
        res+=t[pos];
    return res;
}

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

    cin >> N >> M;
    int i,j;
    for (i=1; i<=N; i++) cin >> arr[i].l >> arr[i].r;

    sort(arr+1,arr+N+1,[](elem A, elem B){ return (A.l < B.l); });

    for (i=1; i<=M; i++)
        for (j=i; j<=M; j+=i)
            d[j].push_back(i);

    int ind=0,val;
    for (i=1; i<=M; i++){
        while (arr[ind+1].l<=i && ind<N){
            ind++;
            update(arr[ind].r);
        }

        for (j=0; j<d[i].size(); j++){
            val=d[i][j];
            ans[val]+=query(min(M,i+val-1))-query(i-1);
        }
    }

    for (i=1; i<=M; i++) cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 19200
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && 0<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int ans[10001]={1};

  REP(i,1,10001) ans[i]=ans[i-1]+i;

  for(int n;cin>>n;cout<<ans[n]<<endl);

  return 0;

}



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main () {
	double a,b,c,s,l;
	cin >> a >> b >> c;
	s=a*b*sin(2*M_PI*c/360)/2;
	l=a+b+sqrt(a*a+b*b-2*a*b*cos(2*M_PI*c/360));
	cout  << setprecision(20) << s << endl << l <<  endl <<2*s/a << endl;
}

Measured memory_bytes: 1284
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int min=200001;
        int ans = 0;
        for(int i=0;i<N;i++){
            int a = scan.nextInt();
            if(a<min){
                min=a;
                ans++;
            }
        }
        System.out.println(ans);
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+1e+5;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int main(){
	int n, l[256];
	cin >> n;
	REP(i,n*2)
		cin >> l[i];
	sort(l, l + 2 * n);
	int ans = 0;
	for(int i = 0; i < n * 2; i += 2)
		ans += l[i];
	cout << ans << endl;
	
}


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

int main()
{
    int n;
    char s[101];
    cin >> n >> s;
    if (n % 2) cout << "No";
    else
    {
        for (int i = 0; i < strlen(s) / 2; ++i)
        {
            if (s[i] != s[i + strlen(s) / 2])
            {
                cout << "No"; return 0;
            }
        }
        cout << "Yes";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A[100000],B[100000],C[100000];
	vint a,b,c;
	vpint saidan;
	scan(N);
	rep(i,N){
		scan(A[i]);
		saidan.push_back(mp(A[i],3));
	}
	rep(i,N){
		scan(B[i]);
		saidan.push_back(mp(B[i],2));
	}
	rep(i,N){
		scan(C[i]);
		saidan.push_back(mp(C[i],1));
	}
	sort(saidan.begin(),saidan.end());
	ll acount=0,bcount=0,ccount=0;
	rep(i,3*N){
		if(saidan[i].second==3){
			acount++;
		}
		else if(saidan[i].second==2){
			bcount+=acount;
		}
		else{
			ccount+=bcount;
		}
	}
	prin(ccount);
	return 0;
}


Measured memory_bytes: 7536
n,k=map(int,input().split())
p=list(map(int,input().split()))
maxim=[0]*(n-k+1)
cnt=0
s=0
for i in range(n):
    cnt+=1
    s+=p[i]
    if cnt==k:
        maxim[i-(k-1)]=s
        cnt=k-1
        s+=-p[i-(k-1)]

ans=(max(maxim)+k)/2
print(ans)


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

int main() {
	char ans[5] = { 'a','i','u','e','o' };
	char c;
	cin >> c;
	for (char a : ans) if (c == a) {
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int N,W,H;
int x[100005];
int y[100005];

int main() {
    cin>>N>>W>>H;

    rep(i,N) {
        int a,b,c;
        cin>>a>>b>>c;
        x[max(0,a-c)]++;
        x[min(100005,a+c)]--;
        y[max(0,b-c)]++;
        y[min(100005,b+c)]--;
    }
    rep(i,W) x[i+1]+=x[i];
    rep(i,H) y[i+1]+=y[i];
    

    bool f1=true,f2=true;
    rep(i,W) f1&=x[i]>0;
    rep(i,H) f2&=y[i]>0;

    if(f1||f2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 1940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;



int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int i,j;
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			printf("%dx%d=%d\n",i,j,i*j);
	
	return 0;
}

Measured memory_bytes: 924
from collections import deque
def bfs(sl, visited, sy, sx, h, w):
    q = deque([(sy,sx,sl[sy][sx])])
    visited[sy][sx] = 0
    bh_cnt = {'#':0, '.':0}
    bh_cnt[sl[sy][sx]] += 1
    while q:
        y, x, bh = q.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y+j, x+k
            if ny >= h or nx >= w or ny < 0 or nx < 0:
                continue
            if sl[ny][nx] != bh and visited[ny][nx] == -1:
                visited[ny][nx] = visited[y][x] + 1
                bh_cnt[sl[ny][nx]] += 1
                q.append((ny,nx,sl[ny][nx]))
    return bh_cnt['#']*bh_cnt['.']


h,w = map(int, input().split())
sl = []
for _ in range(h):
    row = list(input())
    sl.append(row)
visited = [ [-1]*w for i in range(h)]

ans = 0
for hi in range(h):
    for wi in range(w):
        if visited[hi][wi] != -1: continue
        ans += bfs(sl, visited, hi, wi, h, w)
print(ans)

Measured memory_bytes: 82996
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
import collections
n=int(input())

c = collections.Counter(prime_factorize(n))
count=0
for k,v in c.items():
  i=3
  count+=1
  if v>=3:
    while v>2:
      count+=1
      v-=i
      i+=1
print(count)



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

int main()
{
    string date;
    cin >> date;
    int year = 0, month = 0, day = 0;
    year = date[0] - '0';
    int tem = date[1] - '0';
    year *= 10;
    year += tem;
    year *= 10;
    tem = date[2]-'0';
    year += tem;
    year *= 10;
    tem = date[3] - '0';
    year += tem;
    //cout << year << " ";
    month = date[5]-'0';
    month *= 10;
    month += date[6]-'0';
    //cout << month << " ";
    day = date[8] - '0';
    day *= 10;
    day += date[9] - '0';
    //cout << day << " ";
    if(year <= 2019 && month <= 04 && day <= 30)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n;
    cin >> n;

    vl a(n);
    ll x = 0;
    rep(i, n) {
        cin >> a[i];
        x ^= a[i];
    }

    rep(i, n) {
        ll y = x^a[i];
        cout << y;
        if(i < n-1) {
            cout << " ";
        }
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 4800
#include <stdio.h>

#define SMAX 100000
#define TMAX 50000

int main(){

  int i, j, temp, count, snum, tnum, left, right, mid;
  
  int sdata[SMAX];
  int tdata[TMAX];

  count = 0;
  

  //入力
  scanf("%d", &snum);

  for(i = 0; i < snum; i++){

    scanf("%d", &sdata[i]);

  }
 
  scanf("%d", &tnum);

  for(i = 0; i < tnum; i++){

    scanf("%d", &tdata[i]);

  }


  //ソート
  /* for(i = 0; i < snum - 1; i++){

    for(j = snum - 1; j > i; j--){

      if(sdata[j] < sdata[j - 1]){
	
	temp = sdata[j - 1];

	sdata[j - 1] =  sdata[j];

	sdata[j] = temp;
	
      }
	
    }
     
    }*/
  

  //検索
  for(i = 0; i < tnum; i++){

    left = 0;
    
    right = snum;

    while(left < right){

      mid = ((left + right) / 2);

      if(tdata[i] == sdata[mid]){

	count++;
	//printf("%d ",tdata[i]);
	break;

      }

      else if(tdata[i] > sdata[mid]){

	left = mid + 1;

	while(sdata[left] == sdata[left + 1]){
	  
	  left++;

	}

      }

      else{

	right = mid;

	while(sdata[right] == sdata[right -1]){
	  
	  right--;
  
	}

      }

    }

  }
  
  printf("%d\n", count);

  return 0;

}

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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d > 0 && d * d > 4 * a * b) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}


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


int main(){
  int fla=0,cou,sum,b;
  char a;
  while(1){
    sum=0;
    cou=0;
    while(1){
      scanf("%d%c",&b,&a);
      if(b>=10)sum+=10;
      else sum+=b;
      if(b==1)cou++;
      if(a=='\n')break;
    }
    if(sum==0)break;

    for(int i=0;i<cou;i++){
      if(21-sum>=10)sum+=10;
      else break;
    }
    if(sum>21)cout << "0"<<endl;
    else cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h> 
using namespace std;
const int N = 10101;
char s[10];
int n,ans,a[101];
int main() {
	scanf("%d",&n);
	for (int i = 1;i <= n; i++)
		scanf("%d",&a[i]);
	for (int i = 1;i <= n; i++) 
		for (int j = i+1;j <= n; j++)
			for (int k = j+1;k <= n; k++)
				if (a[i]+a[j] > a[k] && a[i]+a[k]>a[j] && a[j]+a[k] > a[i] && a[i] != a[j] && a[j]!=a[k] && a[i] != a[k])
					ans++;
	printf("%d",ans);
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int H,W,N;
    cin >> H >> W >> N;

    vector<int> A(N);
    REP(i,N) cin >> A[i];

    auto g = make_vec<int>(H,W);

    int num = 1;
    int i = 0;
    int j = 0;
    int dx = 1;
    for(auto a:A) {
        REP(k,a){
            g[j][i] = num;
            i += dx;
            if(i==-1 || i == W){
                dx *= -1;
                i += dx;
                j++;
            }
        }
        num++;
    }

    REP(i,H){
        cout <<  g[i][0];
        REP(j,W-1) cout << " " <<  g[i][j+1];
        cout << endl;
    }

    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    vector<int> h(n);
    rep(i, n){
        cin >> h.at(i);
    }
    
    int count = 0;
    rep(i, n){
        while(h.at(i)){
            for(int j = i; j < n; j++){
                if(h.at(j)) h.at(j)--;
                else break;
            }
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long L = sc.nextInt();
		long[] a = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
		}

		int j = -1;
		for (int i = 0; i < n - 1; i++) {

			long sum = a[i] + a[i + 1];
			if (sum >= L) {
				j = i;
				break;
			}
		}

		if (j == -1) {
			System.out.println("Impossible");
		} else {
			System.out.println("Possible");
			for (int i = 0; i < j; i++) {
				System.out.println(i + 1);
			}
			for (int i = n - 1; i > j + 1; i--) {
				System.out.println(i);
			}
			System.out.println(j + 1);
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}

}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<ll> ans(M);
  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  UnionFind uf(N);
  ans[M - 1] = N * (N - 1) / 2;
  for (int i = M - 1; i > 0; --i) {
    if (uf.findSet(A[i], B[i])) {
      ans[i - 1] = ans[i];
      continue;
    }
    ans[i - 1] = ans[i] - uf.size(A[i]) * uf.size(B[i]);
    uf.unionSet(A[i], B[i]);
  }
  REP(i, M) cout << ans[i] << endl;
}

Measured memory_bytes: 3328